Author Topic: PIC18 timer help  (Read 1254 times)

0 Members and 1 Guest are viewing this topic.

Offline Ground_LoopTopic starter

  • Frequent Contributor
  • **
  • Posts: 712
  • Country: us
PIC18 timer help
« on: January 11, 2021, 07:17:21 pm »
I'm trying to use a timer in a PIC18F27Q10.  It looks like registers TMRxL and TMRxH store the period value for the timer according to the MCC setup page.  However, the data sheet says these registers are used for the accumulated value.  I need to set specific accumulated values (reset the count to zero) without altering the overall period value.  I don't see how to accomplish that or understand how the timer operates if the registers are one in the same.  Please help.
« Last Edit: January 11, 2021, 07:53:02 pm by Ground_Loop »
There's no point getting old if you don't have stories.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 14135
Re: PIC18 timer help
« Reply #1 on: January 11, 2021, 08:17:38 pm »
Odd numbered timers don't even *HAVE* a period register.  They roll over from 0xFFFF to 0x0000.   However it is possible to configure a CCP module to clear its odd numbered timer on compare match, effectively using its CCPRx SFRs a the limit register for the timer.

In general you should always believe the datasheet (as corrected by any applicable errata) over MCC, unless you have specific evidence to the contrary.
 

Offline Ground_LoopTopic starter

  • Frequent Contributor
  • **
  • Posts: 712
  • Country: us
Re: PIC18 timer help
« Reply #2 on: January 11, 2021, 09:29:35 pm »
Yea, I figured out the roll over part.  I decided to set it up as a self interrupting timer with timer 3 as the clock source, that stops on roll over and is then externally restarted.  It's not elegant, but it works for my purposes.
« Last Edit: January 11, 2021, 09:55:54 pm by Ground_Loop »
There's no point getting old if you don't have stories.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->