1
\$\begingroup\$

I'm new to the forum, have no electronics background and I've just started learing PIC programming (Mplab X c-compiler) so please forgive me if this question is irrevelant, stupid or both.

Short background to my question:

  • There is a lot of info in datasheets and on forums about reading 16 bit timers on 8-bit PIC:s and I think that I have a basic understanding of the overflow problem that could occur when reading the high and low registers separatly.
  • I've seen that some PIC18 (e.g. PIC18F45K22) have a hardware buffer of the high register to avoid this problem.
  • I'm using the timer1 module of a PIC16F1783. In my understanding this timer can count EXTERNAL signals in both ASYNC and SYNC (at least for moderately fast signals) mode.

My question:

  • In the datasheet for the PIC16F1783 on page 177 (http://ww1.microchip.com/downloads/en/DeviceDoc/40001579E.pdf) there is a paragraph called: "READING AND WRITING TIMER1 IN ASYNCHRONOUS COUNTER MODE".
  • For the PIC1845K22 there is a similiar paragraph on page 165 (http://ww1.microchip.com/downloads/en/DeviceDoc/41412F.pdf).

  • Why does is say ASYNCHRONOUS here? Wouldn't the same problem occur if timer1 was used as external SYNC counter OR internal/external timer?

  • Does it mean that it's somehow possible to read both the high and low registers consecutively and get a valid read when external SYNC counter mode is used (even without hardware buffers or software tricks)?

Thanks for your time! Kind regards / Henrik

\$\endgroup\$
1
\$\begingroup\$

It say asynchronous here because using this mode gives the possibility for extra problems. Because the counter increment is not synchronized to the clock there may be a case where an increment occurs during a read. The hardware therefore takes care that you get a valid read.

In all cases reading the high byte and low byte is an issue.

\$\endgroup\$
  • \$\begingroup\$ Thanks for you answer! So to summarize: all I ever need to worry about (in both async and sync mode) is the low-high byte issue (?) :-) \$\endgroup\$ – Henrik123 Nov 27 '15 at 18:32
  • \$\begingroup\$ @Henrik123 Yes. \$\endgroup\$ – vini_i Nov 27 '15 at 20:09

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.