Just found out t0con_psa = 1 will disable the prescaler and give me a 1:1 ratio with timer0
t0con_psa is currently 0 in the servo lib, it may need to be changed to = 1. Maybe this will give me consistency on all PICs. Matt. On Saturday, January 23, 2016 at 3:50:01 PM UTC-5, Matthew Schinkel wrote: > > Hi Rob, > > Some midrange PICs have the option of choosing 16 bit instead of 8 bit on > timer0 > > I've found a difference in the prescaller for some timers. Timer 0 on both > PICs have a 1:2 lowest prescaller ratio, where other timers are 1:1. This > explained my trouble with TIMER0 in 16 bit mode on 18f4620. You should use > timer1/2 > > How can the timer lib know what the ratio is without programming every PIC > into the servo lib? Is it enough to go by type? > > If your timer1 sample works, add it to jallib. > > 18F4620 > > T0PS2:T0PS0: Timer0 Prescaler Select bits > 111 = 1:256 Prescale value > 110 = 1:128 Prescale value > 101 = 1:64 Prescale value > 100 = 1:32 Prescale value > 011 = 1:16 Prescale value > 010 = 1:8 Prescale value > 001 = 1:4 Prescale value > 000 = 1:2 Prescale value > > > > T1CKPS1:T1CKPS0: Timer1 Input Clock Prescale Select bits > 11 = 1:8 Prescale value > 10 = 1:4 Prescale value > 01 = 1:2 Prescale value > 00 = 1:1 Prescale value > > > ------------------------------- > 16f1718 > > Prescaler Rate Select bits > 1 : 2 > 1 : 4 > 1 : 8 > 1 : 16 > 1 : 32 > 1 : 64 > 1 : 128 > 1 : 256 > > T2OUTPS<3:0>: Timer2 Output Postscaler Select bits > 1111 = 1:16 Postscaler > 1110 = 1:15 Postscaler > 1101 = 1:14 Postscaler > 1100 = 1:13 Postscaler > 1011 = 1:12 Postscaler > 1010 = 1:11 Postscaler > 1001 = 1:10 Postscaler > 1000 = 1:9 Postscaler > 0111 = 1:8 Postscaler > 0110 = 1:7 Postscaler > 0101 = 1:6 Postscaler > 0100 = 1:5 Postscaler > 0011 = 1:4 Postscaler > 0010 = 1:3 Postscaler > 0001 = 1:2 Postscaler > 0000 = 1:1 Postscaler > > On Saturday, January 23, 2016 at 2:54:42 PM UTC-5, RobH wrote: >> >> >> Hi Matt, >> >> On 01/23/2016 04:42 PM, Matthew Schinkel wrote: >> > Hi Rob, sounds like there is a difference with the PIC timer. Try >> > sample 18f4620_timer3.jal on your PIC to see if you get the expected >> > 1khz signal. >> Could be an issue with the timer or with interrupt handling, or even the >> compiler. >> >> I'm afraid the 16f1718 has no Timer3 and the only 16-bit timer it has is >> Timer1. >> I used that and the output is 990 Hz (with Fosc = 20MHz), close enough I >> would say.. >> >> > I remember now that I tried timer0 on 16 bit mode with the servo >> > library and got incorrect results. I never got around to >> > troubleshooting. Normally timer0 is 8 bit on 18f4620/18f4550. I wonder >> > if you are having a similar issue. I can take a look at this again. >> > T0CON_T08BIT = 0 sets the timer to 16 bit. I'll try with my above >> > timer sample. >> All midrange PICsS have an 8-bits Timer0 (except the brand new 16f18xxx). >> > >> > I've always been able to troubleshoot without reading assembler. The >> > math in JAL is tricky enough with this lib. Use your serial port to >> > output values, and check the math against it. >> I'll see what I can do. >> > >> > I've wondered if we need a timer library to provide a similar API for >> > all timers. This lib would mostly just contain aliases for each timer. >> Seems a good idea ... next issue: find a volunteer! >> >> Regards, Rob. >> >> -- >> *Rob H*amerling - http://www.robh.nl >> > -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/jallib. For more options, visit https://groups.google.com/d/optout.
