This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Capture mode problems in timerA

Hi, 

I encountered some problems in configuring the capture function 2 from P1.3 in timer A  .

First.  when a capture happens,  Should I stop the timer by setting MCX=00, then  read the value from the TACCR2?

Second.  After I read the value,  should I clear the TAR register to make sure the counter starts from 0?

Third,  if the input frequency is low, will it  cause timer A overflow?

Is there anyone could answer my questions.  Thank you very much.

  • Hi,

    abner Simom said:

    First.  when a capture happens,  Should I stop the timer by setting MCX=00, then  read the value from the TACCR2?

    Second.  After I read the value,  should I clear the TAR register to make sure the counter starts from 0?

    Stopping and clearing the timer counter is basically optional. It depends whether it would make it easier for your application. The value in TACCRx will not be changed even if the timer keep running, however if another capture event happens before you read out the data, most probably it will be overwritten. Clearing TAR register can be easily done by setting TACLR bit of TACTL register.

    abner Simom said:

    Third,  if the input frequency is low, will it  cause timer A overflow?

    I guess what you meant is that if the input frequency is high, and the timer counter already overflows before the capture event is received. I think the easiest way to detect this is to set a compare interrupt when the timer overflows to detect the overflow by e.g. incrementing a variable.

  • Hi Leon,

     Thank you very much for your help.  I could continue writing the codes. 

    Best Regards

    Simon.

**Attention** This is a public forum