cancel
Showing results for 
Search instead for 
Did you mean: 

Need Help for Software Trigger OnePulse with Pin output

Elwood Downey
Associate II
Posted on August 12, 2017 at 04:30

Hello,

I have been trying to read the processor doc and piecing together examples but so far no luck. Would appreciate any help. Here are the particulars:

  • I need to set the duration, which may be different each time, and trigger one pulse from software
  • I need an output pin to be High for the pulse duration then go back Low until the next pulse is programmed
  • repeat as necessary
  • I do not care which Timer is used, CPU is stm32f446 or stm32f429

I am developing with CubeMX and HAL libraries.

Thanks for your time.

2 REPLIES 2
S.Ma
Principal
Posted on August 12, 2017 at 07:01

Is the real trigger origin a signal? How time should be managed? Is there a global time counter, or time is reset after pulse is sent?

Any timer with at least 2 channels gpio should be ok for this. If having a series of pulses to generate, choose a timer with dma capability on the CC registers. It is then possible to send a serie of preprogrammed pulses from a ram table.

Elwood Downey
Associate II
Posted on August 13, 2017 at 06:29

Thanks for trying to help.

There is no external trigger. The processor receives some info over USART, does some math, and then wants to start one output pulse and go back to listening for more commands. The length of the pulse is determined by the message and the math so it can be different each time. Messages arrive once per millisecond and the pulses will be between 0 (none) and 10 microseconds long. The pulse length accuracy needs to be controlled to within +- 10 nanoseconds.

I tried just using a GPIO output pin to Set the pin, spin in a loop, then Reset the pin but I could not achieve sufficient accuracy. That's why I thought to use a timer because it can be controlled to within one sys clock period.

The clock is 180 MHz so this should allow me to set the timer period within 5.55 nanoseconds which is better than required. I am using TIM2 and have set the prescaler to 0 to get this full resolution. I tried using OnePulse could never see any output pulse. So now I am configuring TIM2 for output compare. I set the compare value between 0 and 1800 (which should give me a period between 0 and 10 microseconds). But I do not know how to start the timer, and even if I could I do not know how to get the output pin to Set when the timer starts and Reset when it hits the compare value.