2017-10-11 05:33 AM
Hi,
I want to use DMA for transfer data from memory (uint16_t DMA_BUFF[10]) to register TM21.ARR. I want to use TIM6 for generating events every 50 ms for DMA to transfer DMA_BUFF[xx] to TIM21.ARR.
In First 50 ms I want to transfer data from DMA_BUFF[0] to TIM21.ARR, another 50 ms from
DMA_BUFF[1] to TIM21.ARR Etc.
I uses CubeMX, but it looks like, there is little problem with Lib.
This my configuration does not work, nothing from my DMA_BUFF is transfered to TIM21.ARR. Can you help me please?
I set:
1) TIM6 for generating Events for DMA
TIM_MasterConfigTypeDef sMasterConfig;
htim6.Instance = TIM6;
htim6.Init.Prescaler = 1000; htim6.Init.CounterMode = TIM_COUNTERMODE_UP; htim6.Init.Period = 100; if (HAL_TIM_Base_Init(&htim6) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); }sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization(&htim6, &sMasterConfig) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); }2) Set DMA fro transfer
/*DMA for TIM21*/
DMA_HandleTypeDef hdma;hdma.Instance=DMA1_Channel2;
hdma.Init.Direction=DMA_MEMORY_TO_PERIPH; hdma.Init.PeriphInc=DMA_PINC_DISABLE; hdma.Init.MemInc=DMA_MINC_ENABLE; hdma.Init.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD; hdma.Init.MemDataAlignment=DMA_PDATAALIGN_HALFWORD; hdma.Init.Mode=DMA_NORMAL; hdma.Init.Request=DMA_REQUEST_9; HAL_DMA_Init(&hdma);HAL_DMA_Start(&hdma,(uint32_t)&PWM_DMA_BUFF[0],(uint32_t)&TIM21->ARR,1);
3) Run the TIM6
__HAL_TIM_ENABLE(&htim6);
#dma-transfer #dma #tim6 #dma-problem #from-memory2017-10-11 06:08 AM
You need to set TIM6_DIER.UDE. I don't know what's the Cube incantation for this.
JW
2017-10-11 06:51 AM
Thanks for reply, but it still does not work.
I tried to generate interrupt when TIM6 Update events occur and it works fine.So I think that problem could be somewehere in the DMA setting?!
1) My setting of DMA:
DMA_HandleTypeDef hdma;
hdma.Instance=DMA1_Channel2;
hdma.Init.Direction=DMA_MEMORY_TO_PERIPH; hdma.Init.PeriphInc=DMA_PINC_DISABLE; hdma.Init.MemInc=DMA_MINC_ENABLE; hdma.Init.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD; hdma.Init.MemDataAlignment=DMA_PDATAALIGN_HALFWORD; hdma.Init.Mode=DMA_NORMAL; hdma.Init.Request=DMA_REQUEST_9; HAL_DMA_Init(&hdma);HAL_DMA_Start(&hdma,(uint32_t)&PWM_DMA_BUFF[0],(uint32_t)&TIM21->ARR,1);
2) TIM6 setting:
/*Start Tim6 for Generate Events for DMA*/
LL_TIM_EnableDMAReq_UPDATE(TIM6); //LL_TIM_EnableIT_UPDATE(TIM6); // just for check if Update events occur LL_TIM_EnableCounter(TIM6);The source and destination adress is OK, so maybe
hdma.Init.Request=DMA_REQUEST_9; ?
Thanks for help.
2017-10-11 07:40 AM
You can see the content of registers bellow:
Thank you, Jan.
2017-10-11 08:06 AM
Both DMA_CNDTR2=0 and DMA_ISR=0x07 indicate that the DMA has already run into completion.
JW
2017-10-11 09:01 AM
Dunno. Post the content of relevant DMA and TIM registers.
JW