Hi Matt,

I've updated the device files for among others 'bit*2 T0CON_T0CS' for the extended midrange. I've done some compilations for different PICs with a modified version of your servo library (the aliases for option_reg removed) and with timer0, timer1 and timer 3 (18f only). Compilations seem to be OK, but since I don't have a servo I could not test the real thing. Only the 16f1937 gives an error, problem under investigation by Kyle.

While looking at the servo lib I saw a to my opinion 'dangerous' construction in servo_init():

 var byte servo_prescaler = 1
 forever loop
    if servo_steps > 255 then
       servo_prescaler = servo_prescaler + 1 -- increase prescaller
       servo_steps = servo_steps / 2         -- decrease timer steps needed
    else
       exit loop
    end if
 end loop

1. When servo_steps is a large number (don't know how large it can be in practice) an overflow of the prescaler may occur (especially with the extended midrange PICs, which have only a 2 bits prescaler).
2. I maybe wrong but I think that the prescaler should be init'd to 0.
3. And because I find a forever loop always somewhat tricky I suggest to rewrite the code for timer0 to something like:

 var byte servo_prescaler = 0
 while (servo_steps > 255  &  servo_prescaler < 7) loop
                                            -- (3 for ext.midrange)
    servo_prescaler = servo_prescaler + 1   -- increase prescaler
    servo_steps = servo_steps / 2           -- decrease timer steps
 end loop
 if (servo_steps > 255) then
    _warn "servo_steps too large for timer 0"
 end if

For the init-routines of 16-bits timers a similar reconstruction.


You might also check your comments for spelling errors.

Regards, Rob.

--
Rob Hamerling, Vianen, NL (http://www.robh.nl/)

--
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to