I am using an HCS08QB4. I have switch inputs on PTB0-3 and PTB5-7. PTB0-3 and PTB5 are working fine, but PTB6-7 are always reading 0. I have set PTBDD and PTBPE. The two non-working inputs are labelled PTB7/EXTAL and PTB6/XTAL. I am not using an external crystal, but how does the chip know this to use the port pins?
Added p/n to subject.
已解决! 转到解答。
I've answered my own question by looking at the clock control registers. ICSC2 was being set to 0x47 in a demo program and I had copied this without a proper examination. I have changed this back to ICS2 = 0x40 (which is the default) and the external clock is now deselected. The PTB pins are now working correctly as inputs.
I have the reference manual for the MC9S08QB and this does not include OSCOPT0, OSCOPT1 or OSCSC. The available registers are ICSC1, ICSC2, ICSTRM and ICSSC. The clock source select is the top two bits of ICSC1.
I am using the internal clock
ICSC2 = 0x47;
ICSC1 = 0x07; // Internal clock
What I am asking is, are PTB7 and PTB6 available to use as ports as long as the external clock has not been selected or is there another set-up to be done apart from the data direction and pull-ups? Remember, PTB0-3 and PTB5 work. (PTB4 is an output and has not been tested).
I've answered my own question by looking at the clock control registers. ICSC2 was being set to 0x47 in a demo program and I had copied this without a proper examination. I have changed this back to ICS2 = 0x40 (which is the default) and the external clock is now deselected. The PTB pins are now working correctly as inputs.