Using crystal on DEMO board

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using crystal on DEMO board

Jump to solution
863 Views
Iain
Contributor I

CW 5.9, HCS08QE32, DEMOQE

 

I wish to have a 1000Hz clock for TPM timing, and it was suggested by a forum member that that I should set my TPM to use 32kHz crystal XCLK, and prescaler of 32 to give me my 1000Hz clock, and that, I understand. 

Below is code I have to set the ICS (HCS08QE has no ICG).

 

 

ICSC1 = 0b10000000;  // CLKS = 10 external referenceICSC2 = 0b00000110;  // EREFS = 1 oscillator driving crystal,                     // ERCLKEN = 1 ICSERCLK enabledwhile(!ICSSC_OSCINIT){} // wait for external crystal to be initiallised

 

 

I am getting confused by internal/external references, there seems to be more options than I thought there would be, also the EREFS bit I am unsure of, as the book I am using and data sheet seem to contradict each other when mentioning oscillators/crystals/resonators.

 

Basically I just want to set the micro to make use of the 32kHz crystal on my demo board (attatched to EXTAL and XTAL pins),  but am not sure if I am setting the registers correctly, can anyone help?

 

Regards,

Iain

Labels (1)
Tags (1)
0 Kudos
1 Solution
330 Views
bigmac
Specialist III

Hello Iain,

 

I had a closer look at the ICS section in the reference manual, and the fixed frequency clock source is derived differently compared with some of the other HCS08 devices.  For the QE device, the fixed frequency clock, as an alternate clock source for the TPM modules, is derived from the current reference source, whether internal or divided external source.  For other devices, the external source is used.  This means that it would seem possible to use either FEI mode or FEE mode to generate the bus frequency, and also provide the alternate TPM clock.

 

I also see that there is an additional frequency division by 2, before the clock is applied to the TPM prescaler, that I had previously overlooked. This means that the clock frequency will be nominally 16 kHz.

 

Accepting that you still require to use an external reference, I believe that the ICSC1 value should be 0x00 in order to source the bus clock from the FLL.  A setting of 0x80 would be causing FBE mode, giving a 16 kHz bus frequency  - not what you require.   A nominal bus frequency of 4 MHz should be achieved with ICSC2 = 0x44; and ICSSC = 0x00;

i.e. Bus frequency = 32768 * 512 / 2 / 2

 

Regards,

Mac

 

View solution in original post

0 Kudos
1 Reply
331 Views
bigmac
Specialist III

Hello Iain,

 

I had a closer look at the ICS section in the reference manual, and the fixed frequency clock source is derived differently compared with some of the other HCS08 devices.  For the QE device, the fixed frequency clock, as an alternate clock source for the TPM modules, is derived from the current reference source, whether internal or divided external source.  For other devices, the external source is used.  This means that it would seem possible to use either FEI mode or FEE mode to generate the bus frequency, and also provide the alternate TPM clock.

 

I also see that there is an additional frequency division by 2, before the clock is applied to the TPM prescaler, that I had previously overlooked. This means that the clock frequency will be nominally 16 kHz.

 

Accepting that you still require to use an external reference, I believe that the ICSC1 value should be 0x00 in order to source the bus clock from the FLL.  A setting of 0x80 would be causing FBE mode, giving a 16 kHz bus frequency  - not what you require.   A nominal bus frequency of 4 MHz should be achieved with ICSC2 = 0x44; and ICSSC = 0x00;

i.e. Bus frequency = 32768 * 512 / 2 / 2

 

Regards,

Mac

 

0 Kudos