matt_at_hanbay
Joined: 06 Jul 2007 Posts: 15 Location: Montreal Canada
|
|
Posted: Thu Sep 20, 2007 4:59 pm |
|
|
Problem resolved. Maybe this will help someone else.
So.. the issue was that I was increasing the frequency by decreasing the value of PR2. For example, the current period may be 65, and I was decreasing it to 55. the PR2 value is double buffered, and the logic is smart enough that if TMR2 is very close to the current PR2 (eg 65), the new PR2 value will not be written into the register. This prevents PR2 from being updated while it is being read. However... it does not protect against weak code! If for example TMR2 is 56, and you try to change PR2 to 55, it will be updated, but TMR2 has already passed 55, so it will count all the way to 255 before restarting and counting up to our period of 55. This will cause a period of 255+55 instead of just 55. (3x the correct period). This cause sufficient missed step pulses to stall the stepper.
In my case the solution was to wait for TMR2 to reset before updating PR2.
Anyways, hope this saves someone else some headache.
-Matt |
|