Reputation: 181
I want to offload the CPU of my STM32G491 by using the DMA function. I want to use the Timer 2 (TIM2) to generate four moments where a DMA transfer is needed. While doing so I can create two pulses in one period. The period, duty cycle, and the delay are adjustable by using the Timer Output Compare functions.
int amplitude = 0xFFF;
uint16_t current[] = {0, amplitude, 0, amplitude};
HAL_DAC_Start_DMA(&hdac1, DAC_CHANNEL_1, (uint32_t*) ¤t[0], sizeof(uint16_t), DAC_ALIGN_12B_R);
HAL_DAC_Start_DMA(&hdac1, DAC_CHANNEL_1, (uint32_t*) ¤t[1], sizeof(uint16_t), DAC_ALIGN_12B_R);
HAL_DAC_Start_DMA(&hdac1, DAC_CHANNEL_1, (uint32_t*) ¤t[2], sizeof(uint16_t), DAC_ALIGN_12B_R);
HAL_DAC_Start_DMA(&hdac1, DAC_CHANNEL_1, (uint32_t*) ¤t[3], sizeof(uint16_t), DAC_ALIGN_12B_R);
HAL_TIM_Base_Start_IT(&htim2);
HAL_TIM_OC_Start_IT(&htim2, TIM_CHANNEL_1);
HAL_TIM_OC_Start_IT(&htim2, TIM_CHANNEL_2);
HAL_TIM_OC_Start_IT(&htim2, TIM_CHANNEL_3);
I don't know how I can connect my timers to initiate the transfer of data from memory to the DAC. I hope you can help me give me a direction in the right way.
I have set up my timers so that they give a DMA request when the timer has expired.
While doing so I can create a kind-of biphasic pulse but only for the positive side. The parameters which are adjustable are the two pulse widths, the interphase interval and the period of this pulse. Note that the negative phase will be positive, so it will output two positive pulses.
Upvotes: 3
Views: 2181
Reputation: 67820
You are configuring it wrong way.
Configure DAC trigger (this trigger will force DAC to request data transfer)
Configure timer to generate apripiate trigger
Upvotes: 1