cancel
Showing results for 
Search instead for 
Did you mean: 

Read output state of Timer

marek2399
Associate II
Posted on October 28, 2017 at 18:54

Hello engineers,

could someone help me with one issue? Iam finding way to read output state of timer but unsuccessfull. I have one timer triggered by Comparator. This timer is configured as one pulse and is master for another timer which is configured in gated mode. Any advice for reading state of one pulse timer?

Many thanks

6 REPLIES 6
Omar BOUZOURRAA
Associate II
Posted on October 28, 2017 at 20:27

Hello,

Yo can simply enable CCR interrupt in one pulse Timer. In the corresponding CallBack you increment a variable. This variable will show you how much the Timer output state has changed.

Posted on October 28, 2017 at 20:54

The physical pin is readable via GPIOx->IDR, I'd expect it would work as an EXTI input regardless of the peripheral assignment. The Internal status of the TIM can be seen via the SR, CNT, and CCRx registers.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on October 28, 2017 at 21:38

Hello,

Arent those registers just for settings?

Posted on October 28, 2017 at 21:50

No, not exactly. Status will reflect things, I'd expect CCx to signal in SR, I'd expect CNT to reflect current phase, and CCRx on the indirect channel to be usable to latch things. You'd likely need to experiment to get the info you're looking for, but I think the hardware should be able to report things you can use.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on October 29, 2017 at 16:11

Hello Clive,

The SR is only status register of interrupt flags. To clarification i will describe my problem.

I have ADC REG channel triggered by TIM15. Tim15 is slave in trigger mode and TIM16 is master. TIM16 is one pulse timer. But i have also INJ channels which i want to use measure significant datas(temperature,voltage,current). INJ channels cannot be used for DMA thus i used REG channel for major measurement. when REG channel is not active (the TIM16 is in 0) i need to measure INJ channels continuously. That is why i cannot use edges for detecting. INJ cannels are started by sw from main while loop. and i need to check before every sw start of INJ channels if timers output is in 0 or 1.

Please help me.

Posted on October 29, 2017 at 21:30

I don't understand why do you need this, but if you trigger an interrupt upon compare and update, you can keep simulate the state of output in software - this is basically the same as Omar said above.

JW