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).
Anonymous
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
Evening,
Prescale of 16 would be T2CON=0b01111110 (i.e. T2CKPS=0b10 rather than 0b11). Does gpsim implement prescale of 64?
..Remy
Bingo
Patch on way
Add class T2CON_64 which supports prescaleof 64 and use for p1xf182x processors in svn 2429
Might need to extend this to F18xx but will check my PIC12F1840 in morning :)
New class was also added to p12f1840 and p16f1788