Hi Rob,
$FFAF is where the programmer will put the trim value it calculates if you ask it to.
Here is the piece of code that moves it to the active register:
// Function for switching to an internal clock mode (FEI or FBI)
void ics_intclk(byte C1, byte C2) {
byte i;
if (NVICSTRM != 0xFF) {
ICSTRM = NVICSTRM; // load trim value if location not blank
}
This form of sanity check on the nonvolatile value is quite stupid even though it appears in most examples that I have seen. I actually prefer to do no sanity check (even though I said to do one before). The reason for this is.....
Failing to write to the trim register results in a value of $80, this value in a fair proportion of cases will result in a SCI that works and another fair proportion that will be marginal. The rest won't work due to baudrate mismatch. Writing an uninitialised value of $FF will result in a baudrate that never works which is far better than one that "sort of" works. This is because I have never seen a device that needs a trim value bigger thatn about $B0. Of course if you want to be fussy you could identify the un programmed non-volatile register and do something else to prevent it getting shipped. But blindly allowing the reset value to remain there is just asking for trouble.
BTW they are ignoring the fine trim here. It is not necessary as the main trim will get you close enough for correct SCI operation. Also I find that it seems to be beyond the ability of the BDM/software to calculate it correctly anyway.
Message Edited by peg on 2007-04-1104:17 PM