> 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.

Thank you very much for your hard work on this Rob, I will do some
testing when I get a chance. You don't need a servo, you can see the
wave on your scope which should be from .5ms to 1.5ms

> 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.

I don't think any PIC will get through all of the prescallers.
Possibly at extreem OSC rates. 48mhz seems to be ok, but a safety
check is always a good idea!

> You might also check your comments for spelling errors.

My spelling is horrible... I wish Jaledit had a spell checker for
comments! I'll put it through word.

Matt.

-- 
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