I am trying to use a 16 Mhz external oscillator for both the CPU clk and the BUSCLK, but am having difficulty in getting it to operate correctly. The reason for wanting to use the external oscillator is so that no trimming of the internal clock would be required.
Using the internal clock, some chips exhibit baud rate errors without trimming. I tried to use the initializer, to use the FBE mode, but the debug module fails displaying "frequency change to ~0 hz, repeatedly.
The setting from the initializer that works is
ICGC1 = 0x46
ICGC2 = 0x00
The setting that I tried to change to is
ICGC1 = 0x52
ICGC2 = OX03
Any suggestions?
Thanks,
Jerry
Hello Jerry,
Are you attempting to use an external packaged oscillator (single EXTAL connection), or an external crystal resonator (with two connections)? If using the latter, the ICG1 setting is incorrect. The REFS bit, and possibly the HGO bit, would need to be set.
Note that some of the bits of ICG1 are write-once only after a reset.
Regards,
Mac
I am using a packaged oscillator.
I also noticed that after I program the chip and inspect location 0xFFBE, it already has a value in the range of 0x85-0x8A. Where does this value come from? I inspected the various startup code and MCUinit, and don't see where this value originates.
Jerry
Hello Jerry,
The flash location 0xFFBE is designated as storage for the ICG calibration value, and this value should usually be loaded into the ICGTRM register by program code, to obtain a calibrated internal clock frequency.
It is possible that the calibration takes place automatically, during the flash programming process. The median calibration value is 0x80.
With respect to the previous problem, are there similar issues when you attempt to initiate and use FEI mode? I wonder if there are COP timeout problems, but this should occur for either ICG mode. Have you been able to verify that the packaged oscillator is actually producing output with the correct voltage swing?
Regards.
Mac
Hi Bigmac,
Thanks for your suggestions. I have a combination that works
ICGC1 = 0x54
ICGC2 = 0x01
The difficulty may have been with the Device Initiializer and the various sequence and changes that I went through before landing on this configuration. I continually would get different warnings with various combinations of "Source CPU clock" and "External Clock"....it wasn't as straight forward as I thought it should be, although, again, it could have been a settings sequence issue.
1) Source CPU clock External Clock 16.0 MHz
2) Initialize trim value no
3) External Clock Enabled
3a) Oscillator Frequency 16.0 MHz
3b) External Clock Source External oscillator
4) Clock divider Auto Select
4a) Internal bus clock 4.0 MHz
5) FLL clock Disabled
The difficulty with the BDM mode "went away...???", and that could be due to getting the chip into some wierd mode. The error message from the debugger was a repeated "changing frequency to 0Hz"
The "automatic" creation of the value stored for ICGTRM @ 0xFFBE looks like comes from the programmer, "CPROGHCS08 Programmer" , but since I am not using the internal clock, I think the point is moot.
Anyway, thanks for replying....it is nice to know that there is some help out there and people like you are willing to spend some time.