Menu

#233 pic12f1822: timer2 uses wrong clock

None
closed-fixed
None
5
2017-10-28
2017-10-20
Remy Horton
No

Within gpsim r2428 the attached program toggles RA0 every second, whereas on a physical PIC12F1822 chip it toggles every 4 seconds. This is likley due to the input of the timer2 prescaler using Fosc (system clock) rather than Fosc/4 (instruction clock).

1 Attachments

Discussion

  • Roy Rankin

    Roy Rankin - 2017-10-26

    Remy,

    Gpsim seems to be doing the right thing.
    loop = 100
    PR2 = 160
    Prescale = 16
    Postscale = 16

    loop * PR2 * Prescale * Postscale = 4,096,000
    Fosc/4 = 4,000,000 cycles/sec for 16MHz clock
    So RA0 should toggles about 1/sec

    Roy

     
  • Remy Horton

    Remy Horton - 2017-10-27

    Evening,

    Prescale of 16 would be T2CON=0b01111110 (i.e. T2CKPS=0b10 rather than 0b11). Does gpsim implement prescale of 64?

    ..Remy

     
  • Roy Rankin

    Roy Rankin - 2017-10-27
    • assigned_to: Roy Rankin
    • Group: -->
     
  • Roy Rankin

    Roy Rankin - 2017-10-27

    Bingo
    Patch on way

     
  • Roy Rankin

    Roy Rankin - 2017-10-28
    • status: open --> closed-fixed
     
  • Roy Rankin

    Roy Rankin - 2017-10-28

    Add class T2CON_64 which supports prescaleof 64 and use for p1xf182x processors in svn 2429

     
  • Remy Horton

    Remy Horton - 2017-10-28

    Might need to extend this to F18xx but will check my PIC12F1840 in morning :)

     
  • Roy Rankin

    Roy Rankin - 2017-10-28

    New class was also added to p12f1840 and p16f1788

     

Anonymous
Anonymous

Add attachments
Cancel