AnsweredAssumed Answered

Configuring STM8S003F3U to measure a pulse length using TIM1_CHANNEL1_N

Question asked by madinger.noah.002 on Mar 5, 2018
Latest reply on Mar 6, 2018 by dhenry

I am using STM8S003F3U.  This MCU is being used with a SPIRIT1 transceiver. Using OOK modulation, the SPIRIT1's raw data is being sent to pin PC3 on the MCU.   Because my transmitter's data rate is inconsistent, I need to be able to measure the pulse HIGH time of the data coming across.  To do this, it is my belief that the following needs to be done:

 

1) Configure PC3 to its alternative pin function (TIM1_CHANNEL_1_N).  I do not know how to do this.  Can someone provide a code example?

2) Configure the TIM1 capture channel with two ISRs (one for rising edges and one for falling edges), so that the pulse time can be measured.  There is some rudimentary code from ST, but it is unclear how to do this.  Can someone provide a code example?

 

Once these two steps are complete, I can derive the bit rate and decode messages.  Any help that can be provided is much appreciated!

 

Thank you,

 

Noah

Outcomes