cancel
Showing results for 
Search instead for 
Did you mean: 

arbitrary waveform using DMA and timer

Samuel1
Associate III

Hello,

i am trying to generate arbitrary waveform. But it still dose not work. I think it's up to the configuration. I have created a array of 6 words for two waveform patterns to be send to TIM1 channel 1 (TIM1_ARR, TIM1_RCR, TIM1_CCR1) This is how the basics look

uint32_t aSRC_Buffer[6] = { 2000,1,800,3000,2,200}; /// ARR, RCR, CCR1 x 2. But i am just getting a 3.3 V on the PIN.

uint32_t aSRC_Buffer[6] = { 2000,1,800,3000,2,200}; 
 
 
HAL_TIM_DMABurst_WriteStart(&htim1,TIM_DMABASE_ARR, TIM_DMA_TRIGGER,
(uint32_t *)aSRC_Buffer, TIM_DMABURSTLENGTH_3TRANSFERS);

 #DMA​ #DMA​ #TIMER​ 

7 REPLIES 7

Perform the writes to those registers "manually". Does the pin voltage change?

jW

Samuel1
Associate III

​@Community member​  the pin is high because i have set the GPIO Mode to Pull-up

Well, if you set it to pull up (and presumably as Input?) and you find it high, then it works exactly according to your setting, doesn't it?

What's the problem then?

JW

Samuel1
Associate III

​i am trying to generate Waveform Pattern with DMA and Timer. the DMA should send the Data to the TIM1_CH1. but it dose not work. Somehow i dont see the DMA configuration in the main.c i do not know why. i just can see the following:

static void MX_DMA_Init(void) 
{
  /* DMA controller clock enable */
  __HAL_RCC_DMA2_CLK_ENABLE();
 
  /* DMA interrupt init */
  /* DMA2_Stream5_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(DMA2_Stream5_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA2_Stream5_IRQn);
 
}

Samuel1
Associate III
HAL_TIM_Base_Start(&htim1);
HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_1);
HAL_TIM_DMABurst_WriteStart(&htim1,TIM_DMABASE_ARR,TIM_DMA_UPDATE,
(uint32_t *)aSRC_Buffer, TIM_DMABURSTLENGTH_3TRANSFERS);

Start with getting PWM output on that pin, without DMA.

JW

S.Ma
Principal

If you want to generate a burst of pulses of different timings on a pin, you select a Timer which can be DMA access for its CHANNEL register. Create the toggle points over the course of a timer period and feed this toggle timestamps cyclically to the channel output compare as toggle point.

The timer period should remain fixed.