View previous topic :: View next topic |
Author |
Message |
Go4Linux
Joined: 11 Sep 2014 Posts: 7
|
Posted: Fri Jan 16, 2015 9:14 am Post subject: Config Servo with 12MHz Crystal fails? |
|
|
Hi everybody, i tryed to do some Servo tests with config Servo. Using a Tiny24 everything works well. Using a Mega8 with a 12MHz external crystal - problems:
using this code snippet:
Code: | $regfile = "m8def.dat"
'$crystal = 12000000
$crystal = 8000000
Ddrb = &B00000010
Config Servos = 1 , Mode = Servo , Servo1 = Portb.1
Servo(1) = 100
Do : Loop |
It compiles, but if you change to 12MHz crystal you get an error on compile, that the prescaler must be set. Ithought it's automatically calculated? Anyway - setting to 1 gives a 10 times too fast timing for the servo protocol.. What values do i need to set for prescale (,reload?), in order ot reach a proper servo timing with this crystal? So 1ms hign and 19ms low? Maybe it's just not possible with every crystal?
Could somebody compare?
can i simulate the output of portb.1 in my example (just tosee the timing in comparision to the cycles)?
Thanks in advance!
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Fri Jan 16, 2015 10:30 am Post subject: |
|
|
Try read Wiki with examples
http://wiki.mcselec.com/bavr/CONFIG_SERVOS
8 bit Timer0 is used so prescaler must be selected that it can accommodate 2ms interval.
Quote: | The prescale parameter overrides the automatic calculation. |
|
|
Back to top |
|
|
Go4Linux
Joined: 11 Sep 2014 Posts: 7
|
Posted: Fri Jan 16, 2015 10:55 am Post subject: |
|
|
EDC wrote: | Try read Wiki with examples
http://wiki.mcselec.com/bavr/CONFIG_SERVOS
8 bit Timer0 is used so prescaler must be selected that it can accommodate 2ms interval.
Quote: | The prescale parameter overrides the automatic calculation. |
|
But i do want to use the "automatic calculation" (so give no prescaler value at all)
And it works with 8MHz - why not with 12MHz?
( i did read all the explainations) |
|
Back to top |
|
|
Go4Linux
Joined: 11 Sep 2014 Posts: 7
|
Posted: Fri Jan 16, 2015 10:57 am Post subject: |
|
|
The question could also be: "Why does the code compile with the one crystal setting and does not compile with the other crystal setting?"
I would expect that the timing is different, but not that the compiler behaves differently.. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue Jan 20, 2015 3:41 pm Post subject: |
|
|
when you use mode=servo, a different algo is used. it gives lower processor load but the prescaler need to be around 255 for 2 ms. if that is not possible the timing is way off.
you could however supply the prescaler yourself to override the calculation. like : Config Servos = 1 , Servo1 = Portb.1 , Prescale = 256 , Mode = Servo _________________ Mark |
|
Back to top |
|
|
|