I want to reset the timer before the timer interrupt.

In my case, I will use the Mod bus protocol for serial port. I had to reset the timer for each byte sent and send data if the timer reach 3.5 ts(Time for sending byte). It mean if we didn't receive any byte until (3.5ts s ) we send data, if not, we add new data in the buffer.

So in this case, I want to use two interrupts:

  • One interrupt for the serial port Rx. In this interrupt I will reset the timer.
  • One interrupt for the Timer where I will send the Buffer.
  • 2
    \$\begingroup\$ Capitalization and punctuation will help make your question readable. \$\endgroup\$ – JYelton May 5 '14 at 7:15
  • 1
    \$\begingroup\$ It's not clear what is asked here. You wan't to know how to implement what you described? Because right now it's not a question, but just a description of what you are doing. \$\endgroup\$ – Blup1980 May 5 '14 at 11:19

Whenever you receive a byte, UART will generate an interrupt.In that ISR you can reset your timer to indicate that you have to wait for 3.5 bit time from now.

I never used this perticular controller, but to reset the timer, You can write 0 in it's timer/counter register OR there might a bit through which you can reset the timer. On checking datasheet, If you could set command to RESTART i.e. 10 in CTRLFSET register, it will restart the timer.

Everytime you recieve a byte, you will reset the timer and if no byte is recieved in 3.5 Bit time, Your timer interrupt will be generated and through that you can initiate the transmission!

  • \$\begingroup\$ thanks i had jut to use TCD0.CNT=0x0000; to rest the timer before the ISR \$\endgroup\$ – cherev May 6 '14 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.