cancel
Showing results for 
Search instead for 
Did you mean: 

Triggered Arbitrary PWM with DMA, how to?

NRoth.3
Associate II

NUCLEO-H723ZG

I would like to have a triggered Arbitrary waveform from a Timer.

A defined pattern should be generated, after a Trigger from another Timer.

The arbitrary pattern works well by DMA, but i cannot trigger it.

It's also possible to let it run continously when i disable One Pulse Mode.

But with One Pulse Mode ON, the DMA Update is issued after the next Timer Trigger and not after the last Pulses!

I have DMA Update at TIM_DMA_UPDATE. But TIM_DMA_UPDATE is trigegred when the master Trigger rises. So the DMA is incremented after each Master Trigger.

All samples i found are contiously running..

I dream of a smart Solution with timer settings. Any Ideas/suggestions?

Tnx

2 REPLIES 2

Try to post concrete information about your setup.

JW

NRoth.3
Associate II

Thank you so much so far.

Seem s i need be more detailed.. sorry.

Using CubeIDE 1.12.0 with HAL.

I have TIM4 as Master Timer with TRGO Output UpdateEvent. It produces a fixed cycle (now: 1kHz)

Then i setup TIM1 as Slave: TriggerMode, Trigger Source ITR3, Channel1: PWM CH1, One Pulse Mode

DMA Settings on TIM1: DMA Request: TIM1UP, Circular, HalfWord

Some code:

uint16_t const aSRC_Buffer[] = {5,4,2, 11,4,1, 19,4,14, 50,4,5}; //test pattern
 
HAL_TIM_PWM_Start_IT(&htim1, TIM_CHANNEL_1);  
 
 HAL_TIM_DMABurst_MultiWriteStart(&htim1, TIM_DMABase_ARR, TIM_DMA_UPDATE, uint32_t*)aSRC_Buffer, TIM_DMABURSTLENGTH_3TRANSFERS, 12);

--> The Result is:

Each of this 4 Patterns is sent out. BUT always one single Pattern after the Master Trigger and not one after the other!

-->The Result when switching TIM1 OneShot Mode OFF:

Each of the 4 Patterns is sent one after the other, BUT it doesnt stop when the 4 patterns are sent!

Its continously running.

I can do it by using Interrupts and Start/Stop the Timer:

void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim){
	if (htim == &htim4 ) {
	  HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
	}
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){
	HAL_TIM_PWM_Stop(&htim1, TIM_CHANNEL_1);
}

But this is the ugly methot in my view.

Still hope there is a way without interrupts..