Propeller OS versions - what about CLKFREQ & CLKMODE ?
Cluso99
Posts: 18,069
A few of us have developed different OSes for the Prop. This question is more of a common issue to all of these OSes...
Let me describe the background/usage first.
I regularly move my microSD card between my various prop boards. This is not a normal situation as most users probably use the one SD card for a board type.
My EEPROM BOOT program only knows which pins the SD card uses. It then reads the SD and looks for the file AUTOEXEC.BAT and if found, will read this file to get a filename of the binary prop file on the SD card to boot from. If this file is not found, or autoexec.at is not found, then the program will read the file BOOTPROP.BIN on the SD card and boot from this. If this file is not found either, the program stops.
My OS program on the SD card can determine a number of different hardware types (a standard prop board, or one of RamBlade, TriBlade, RamBlade3 - I can tell my different boards from pullups on different pins).
However, what I cannot tell is the xtal frequency (5MHz, 6MHz, 6.5MHz and occasionally 13.5MHz) because I often change these (they are socketed).
Once the OS is loaded, I can call various OS commands. These are all modules which use a now resident set of routines and mailboxes to communicate. Currently, I have to recompile all the OS for different clock frequencies, but I don't need to do this for the various hardware. So I am thinking of changing my loader to keep the existing clock frequency and mode.
My OS can also reload any prop binary, and that binary can return to the OS by a prop reboot. (eg I can boot ZiCog/CPM and a HALT command will reboot the prop).
The Problem and Possible Solution(s)...
I want to be able to produce prop binaries that do not require recompiling. But they may be used on hardware with different clock frequencies and modes.
Does anyone have any other suggestions?
Let me describe the background/usage first.
I regularly move my microSD card between my various prop boards. This is not a normal situation as most users probably use the one SD card for a board type.
My EEPROM BOOT program only knows which pins the SD card uses. It then reads the SD and looks for the file AUTOEXEC.BAT and if found, will read this file to get a filename of the binary prop file on the SD card to boot from. If this file is not found, or autoexec.at is not found, then the program will read the file BOOTPROP.BIN on the SD card and boot from this. If this file is not found either, the program stops.
My OS program on the SD card can determine a number of different hardware types (a standard prop board, or one of RamBlade, TriBlade, RamBlade3 - I can tell my different boards from pullups on different pins).
However, what I cannot tell is the xtal frequency (5MHz, 6MHz, 6.5MHz and occasionally 13.5MHz) because I often change these (they are socketed).
Once the OS is loaded, I can call various OS commands. These are all modules which use a now resident set of routines and mailboxes to communicate. Currently, I have to recompile all the OS for different clock frequencies, but I don't need to do this for the various hardware. So I am thinking of changing my loader to keep the existing clock frequency and mode.
My OS can also reload any prop binary, and that binary can return to the OS by a prop reboot. (eg I can boot ZiCog/CPM and a HALT command will reboot the prop).
The Problem and Possible Solution(s)...
I want to be able to produce prop binaries that do not require recompiling. But they may be used on hardware with different clock frequencies and modes.
- Modify the loader to keep the existing clock frequency and mode.
- Add an OS program to change the EEPROM boot program clock frequency and mode bytes on the eeprom.
- Alternately, read a file on the SD to obtain the clock frequency and mode.
Does anyone have any other suggestions?
Comments
This would allow a six bit multiplier value (leaving headroom for a Prop3) and base clock frequencies up to 64MHz+change.
Spinix requires re-building the boot program to change the clock configuration. Any program that is run under spinix will run at the clock frequency set by the boot program.
I suspect normal users do not change the xtals. Anyone care to comment???
It is easy enough to rewrite the first 5 eeprom locations of the boot code with a new clkfreq and mode. That way the boot code would know, and all other program loads could skip over these locations during a load.
In RCFAST mode, the program would need to time the baud first???
I am just looking to see if there are other easy ways of doing this that could be standard.
Isn't RCFAST and RCSLOW too imprecise for baud serial IO, so why bother? Maybe I missed the point.
This has come up at least once before. The problem is that there's no minimum hardware that includes some kind of time standard. The minimum hardware would normally include an EEPROM and sometimes a serial connection to a PC. The serial connection might be absent if you're using some kind of display and keyboard / keypad and it might be absent with a device that doesn't communicate with a user. You could store the clock frequency in EEPROM somewhere other than the 1st 32K, but you might have changed the crystal since the EEPROM was written last. On the Prop 2, the internal RC oscillator might be able to be calibrated well enough and a "hint" stored in a few bits of the fused PROM that would get you close enough to figure the crystal frequency to the nearest MHz or 0.5 MHz or so, but I don't know what to do with the Prop 1
Yes, the boot code does crude auto-bauding, but a loader byte is not 8 bits. A single 4 "byte" packet is actually 21 bytes with the 4 bytes encoded. That allows for the slop inherent in the RCFAST mode. The entire protocol is fairly interesting. I've never seen an RCFAST propeller that could do even a slow bit per bit baud rate precisely.
If connected to a terminal, you could just step through different setting and output "hit enter" until the terminal displays "hit enter" and the app sees a proper CR-LF. If you only use a couple, like 9600 and 57600, and you only have four valid crystals, it should only take a few seconds.
IMHO 115,200 baud is fine for a max, at least for this section.
Thank you for this very nice little program. I get 116,504 baud. How are you converting this to MHz? How to add a statement in the program to also display MHz? This is very useful!
Regarding the accuracy limit of the program, has this prop chip already exceeded that limit? Thanks for your reply.
The problem is that at 12 MHz and 230,400 baud there are only 52 clock cycles in a bit time. So the measurement accuracy is now down to 2%. This appears to be enough to mess up the serial timing, even though I think it should work up to a 5% clock error. If you run the autobaud program at 80 MHz it can go up to 1 Megabaud.
So it seems to be a matter of accuracy of the internal crystal for the propeller population more than precision of the individual propeller's frequency. Does the precision change much over a temperature range? That is, will adding more device load to propeller pins (which causes the chip to warm up) change the measured frequency?
Then I stuck it in a small ice chest I use to carry my lunch with a Blue Ice pack. After a few minutes it's now printing 101.7 and 102.6 kbaud. So it appears that the RC clock runs faster at colder temperatures. I would have thought it would be the other way around.
EDIT: After a few more minutes with the Blue Ice it's down to 100.0 kbaud.
EDIT2: After a few more minutes with the Blue Ice it's down to 99.2 kbaud. I checked the Prop Data Sheet, and there's a graph in section 10.1 that shows the RCFAST frequency as a function of temperature. It verifies that the frequency does decrease with increasing temperature.
If you have the prop performing a waitpxx then at some time after the input changes (goes low for the start bit) the prop will continue from this waitpxx instruction. This can be up to almost (say 99%) of a clock width. So, at 80MHz this is 12.5ns. Now you do the opposite waitpxx waiting for the end of the start bit (ie first data bit, presuming it is going to be a "1"). Now this can also be almost up to a clock width. But, if the bit changed just prior to sampling, then between the first and second edges you may have incorrectly counted +/- one clock pulse. This is fine with slow baud, but not for fast ones because +/-12.5ns makes a difference.
A diagram would be better but no time to do this. Perhaps there is an article on the web that explains it better.
Would be nice to repeat experiments and maybe add more data. Maybe someone has access to an environmental chamber.
I don't found what thread You used for question about CPM HD sizes so I post in this one.
Maybe that can help You. Read description in CBIOOS.asm