Prop_Clk
Seairth
Posts: 2,474
in Propeller 2
The only examples of Prop_Clk that I've seen are called with "FF" for maximum(?) clock speed. But I'm having difficulty seeing how it maps to the HUBSET instruction. Does anyone have more thorough documentation, or the boot ROM snippet related to that command?
Comments
EDIT: Err, well, you can apply the workaround rules to the mode numbers now I think about it. Which means a two step process to change to the desired mode.
The clock select flaw workaround would be to precede the desired mode with this fixed mode:
That ensures a clean transition back to RCFAST mode each time before attempting a new mode.
Update: Actually, I think I still need more details. I've updated Google Docs Prop_Clk to distinguish between the chip and the FPGA, but I don't think it's quite right. I'm guessing that the hex bytes are passed the same order as per Prop_Hex (little endian). However, that begs the question: how does the loader know when the command is complete? If updated using only "F0" above as suggested, how does it know that the remaining three bytes aren't going to be transmitted?
And the "Prop_Clk" handling:
EDIT: Included the MOV x,y in the first snippet for clarity.
That aside, assuming the rest matches the ROM, I understand how it works now.
Ok. That happens to be what I updated the example to in the docs. Based on the code above, it means that Prop_Clk always switches back to the 20MHz clock temporarily before switching to the desired clock configuration. I'll make a note of it.
His concern over oscillator settling time may partly be from experience. Most likely that experience has been distorted by brushes with the clock select flaw rather than actual settling times. 5 ms is short though. So what he's proposed is actually another step separate from mine. If both are used then it becomes a three step process to make a setting change.
First step is get cleanly back to RCFAST with $F0. This actually shuts down the crystal oscillator and PLL. Second step is spin up the crystal and PLL without using it. This provides the long settle time that Chip wants. Third step is reissue the same clock settings but just enable the use of it with the least two bit.
The boot code is published - "ROM_Booter_v33_01j.spin2". I can post the source and/or the listing if you can't find it.
IIRC it only autobauds the once when it is in serial mode and sees the "> " characters. I'm not sure what the Prop_Clk command does, but presume it changes the baud setting in the smartpins too.
However, if from the serial boot prompt you enter Ctl-D or Esc to enter the debug/monitor or TAQOZ in ROM, we take the setting from the serial that is already loaded into the smartpins.
The coder needs to know that if he is doing more than one change, for whatever reason, that this flaw is present ... and there a suitable way to handle it.
Maybe note that once the PLL is selected, any future changes there on, from any software, until a chip reset, needs to handle this issue.
PS: Secondary boot loaders and high-level languages are built with a workaround, but pure pasm2 by nature is not and neither is the ROM.
Yes, I see what you are saying.
Whatever the new Prop_Clk frequency is, it can auto-baud to 1/10th the new clock frequency on a subsequent "> " pattern.
It might be good policy to always do a Prop_Clk at the end to return to RCFAST, so that the downloaded code doesn't have to know anything special about the current clock mode.
EDIT: Ah, he's changed it since I last looked. Now uses the prior mode to switch back to RCFAST first. Note the final 100 ms pause to ensure the crystal oscillator fully powers down before moving on.
That wouldn't work, would it? As soon as the load completes, the code starts executing. There's no opportunity to send additional commands.
Oh, you're right. So, the downloaded code would have to know if it was starting under a PLL clock mode with divide=1, if it intended to change it.
Is it always safe to issue a HUBSET #0 (or HUBSET #$F0)? Or do you need to switch back to the internal clock without disturbing the other settings?
Does #$F0 always work? I didn't know about this.
It wasn't accepted as a good idea originally - https://forums.parallax.com/discussion/comment/1466494/#Comment_1466494
Some months later it was put forward again - forgotten where and who. I now use it for short code examples that need to set the clock frequency.
Okay. Just to be clear, please review the Configuring the Clock Generator section, particularly the WARNING paragraph and the example below it.
The official line is use one of two controlled handover methods. Either by always reverting to RCFAST first, called RCFAST handover, or by passing a copy of the currently set mode to the loaded program, called Mailbox handover, at hubRAM address $18. Further reading - https://forums.parallax.com/discussion/comment/1466702/#Comment_1466702