CLKSET in ASM
Helen C
Posts: 34
Hi
I am using Propbasic for a new project that has the following clock set up.
DEVICE P8X32A, XTAL1, PLL16X
FREQ 80_000_000
However I need to put the prop chip into low power sleep mode every so often. I can use the clkset cmd in asm to do this but the prop manual states that you need to write the freqaddr to byte 0 in the main RAM.
So to put it in RCFAST mode the following command works:
\clkset %0000_0000 'set clock to RCFAST
\wrlong 0,#0 'write freqaddr to byte 0
but what I want to know is what freqaddr to use for RCSLOW and then also to put it back to the original settings.
\clkset %0110_1111 'set clock to XTAL1, PLL16X
\wrlong ?,#0 'write freqaddr to byte 0
Thanks and kind regards,
Helen
I am using Propbasic for a new project that has the following clock set up.
DEVICE P8X32A, XTAL1, PLL16X
FREQ 80_000_000
However I need to put the prop chip into low power sleep mode every so often. I can use the clkset cmd in asm to do this but the prop manual states that you need to write the freqaddr to byte 0 in the main RAM.
So to put it in RCFAST mode the following command works:
\clkset %0000_0000 'set clock to RCFAST
\wrlong 0,#0 'write freqaddr to byte 0
but what I want to know is what freqaddr to use for RCSLOW and then also to put it back to the original settings.
\clkset %0110_1111 'set clock to XTAL1, PLL16X
\wrlong ?,#0 'write freqaddr to byte 0
Thanks and kind regards,
Helen
Comments
If this is PASM, forget it. It may work but there is also a big chance that it won't. clkset takes one parameter in its destination slot. Meaning the %0000_0000 you specified is a cog register address. The lower 8 bits from that 32 bit value are written to the clock register. Also, the whole 32 bit value is subsequently written as the frequency value (wrlong). Let's look at an example:
The long at location 0 in cog memory is $5CFC000B (jmpret instruction). So what will happen is that the clock register has %0000_1011 written to it. Then the system frequency is announced as 1_560_018_955Hz. This is very unlikely to work.
If you use PASM for this you can do something like this:
I'm sure you can figure out the other mode settings yourself. If you want to preserve the original values (e.g. current frequency) you'll have to read them from their appropriate location(s). The frequency value for RCSLOW is 20_000 (as used by the propeller tool). Also, if you transition to PLL based modes (e.g. from RCFAST to PLL16X) make sure you do this in two steps as described in manual and datasheet.