2025-04-24 4:56 AM
I am porting code from G473 to U575 because I need more flash and ram.
Then I meet some issues on gpdma transmission size.
For G473, I use dma to transfer data to timer ARR likes:
uint16_t buf[65536] = { ..... };
HAL_TIM_Base_Start_DMA(&htim1, (uint32_t *)buf, 65536);
For U575, the code doesn't work because the size have to be 65536 * sizeof(uint16_t), not the number of buf.
Is there any way to figure it out?
Solved! Go to Solution.
2025-04-24 6:07 AM
The code presented cannot work, either at 65536 or at 65536 * sizeof(uint16_t).
The CNDT register field is 16 bits and accept a maximum value of 65535.
The HAL_TIM_Base_Start_DMA also accept a max value of 65535.
/**
* @brief Starts the TIM Base generation in DMA mode.
* @PAram htim TIM Base handle
* @PAram pData The source Buffer address.
* @PAram Length The length of data to be transferred from memory to peripheral.
* @retval HAL status
*/
HAL_StatusTypeDef HAL_TIM_Base_Start_DMA(TIM_HandleTypeDef *htim, const uint32_t *pData, uint16_t Length)
{
2025-04-24 6:07 AM
The code presented cannot work, either at 65536 or at 65536 * sizeof(uint16_t).
The CNDT register field is 16 bits and accept a maximum value of 65535.
The HAL_TIM_Base_Start_DMA also accept a max value of 65535.
/**
* @brief Starts the TIM Base generation in DMA mode.
* @PAram htim TIM Base handle
* @PAram pData The source Buffer address.
* @PAram Length The length of data to be transferred from memory to peripheral.
* @retval HAL status
*/
HAL_StatusTypeDef HAL_TIM_Base_Start_DMA(TIM_HandleTypeDef *htim, const uint32_t *pData, uint16_t Length)
{
2025-04-24 6:53 AM
Yes, you are right.
Currently, I only use 16384 in G473. But I want to port code to U575 and use more buf in DMA.
And I found the definition is different between G4 and U5 in DMA size.
2025-04-24 6:56 AM
> And I found the definition is different between G4 and U5 in DMA size.
No it's not.
2025-04-24 7:08 AM
In G473, the code below is ok.
uint16_t buf[4] = { ..... };
HAL_TIM_Base_Start_DMA(&htim1, (uint32_t *)buf, 4);
I tried this in U575, buf[2] and buf[3] will not be transfered,unless I set the size = 4 * sizeof(uint16_t).