Delays in PASM Independent of Clock Settings
JohnBF
Posts: 107
I'm working through the PE Kit labs trying to translate as much as possible into PASM. Great learning experience.
What's the best way to run a PASM routine that's independent of system clock settings (as discussed in the lab manual starting on page 49)? You can calculate a delay in spin and pass it to the routine as a parameter. But then if the clock settings change while the routine is running it won't know about it. You can continually update the delay in the routine, but that slows things down.
Attached is a program with·one PASM routine that updates, and one that does not update the delay. I'd appreciate any thoughts on the best way to approach this.
/John
What's the best way to run a PASM routine that's independent of system clock settings (as discussed in the lab manual starting on page 49)? You can calculate a delay in spin and pass it to the routine as a parameter. But then if the clock settings change while the routine is running it won't know about it. You can continually update the delay in the routine, but that slows things down.
Attached is a program with·one PASM routine that updates, and one that does not update the delay. I'd appreciate any thoughts on the best way to approach this.
/John
Comments
Truthfully, you want to avoid changing the system clock all the time. If your concern is power consumption, this can be reduced markedly by having as many running cogs as possible waiting for something to happen either with a WAITPNE/WAITPEQ or a WAITCNT. These all put the cog into a low power mode until the expected change occurs. If you need to drop into a very low power state, say by changing to the slow internal clock or turning off the PLL, the various cogs can coordinate the change when they're in some kind of stable, planned state.