oh and when i first setup this original code, back some years back i refereed to this calculator, so dont use this calc for timer 0 for k40
![]()
oh and when i first setup this original code, back some years back i refereed to this calculator, so dont use this calc for timer 0 for k40
![]()
For the K40 in 8-bit mode I don't see how that gets you 10ms @ 16MHz clock// T0CS FOSC/4; T0CKPS 1:64; T0ASYNC synchronised;
// TMR0H 155;
// TMR0L 0;
// T0OUTPS 1:1; T0EN enabled; T016BIT 8-bit;
Doesn't that get you 156 x 64 x 250ns = 2.496ms ?
yes , my bad it needs to be T0CKPS 1:256;Doesn't that get you 156 x 64 x 250ns = 2.496ms ?
accidently set fosc to 4mhz when trying to match sheldons settings trying to guess at his fosc and forgot to regenerate the code
Warning I'm not a teacher
That'll get you a lot closer... 9.984msit needs to be T0CKPS 1:256
If you use the postscaler you can get 10.000ms:
- set prescaler to 1:32 T0CKPS<3:0> = 0101
- set postscaler to 1:10 T0OUTPS<3:0> = 1001
- set period count = 125 (load TMR0H with 125-1=124)
gets you 32 x 10 x 125 x 250ns = 10.000ms
For 32MHz, just change the prescaler to 1:64:
64 x 10 x 125 x 125ns = 10.000ms
i'm impressed on just how versatile these later generation chips are. there is heaps to learn
Warning I'm not a teacher
also be aware now of the errata on timer0 k40 series , T0ASYNC bit problem , when FOSC/4 clock source
![]()
Bookmarks