AnsweredAssumed Answered

PE generates wrong clock setup for 9S08AC MCU?

Question asked by Sven Kopacz on Apr 19, 2010
Latest reply on Jun 23, 2010 by Sven Kopacz

Hi all,

 

I am using Codewarrior 6.2.2 on a project for the MC9S08AC MCU. I set up Processor Export (3.06) to use the internal ref clock at 226.5 kHz and generate a 8MHz bus clock from that.

(I trimmed the internal clock to match a certain UART requirement, the 8MHz on the other hand dont need to be precise).

Here is a screenshot of my settings:

 

 

 

Am I already doing something wrong here? Because the generated clock setup code is this:

 

 

  /*  System clock initialization */  /* ICGC1: HGO=0,RANGE=1,REFS=0,CLKS1=0,CLKS0=1,OSCSTEN=1,LOCD=0,??=0 */  setReg8(ICGC1, 0x4C);                   /* ICGC2: LOLRE=0,MFD2=0,MFD1=1,MFD0=0,LOCRE=0,RFD2=0,RFD1=0,RFD0=0 */  setReg8(ICGC2, 0x20);                   if (*(unsigned char*)0xFFBE != 0xFF) { /* Test if the device trim value is stored on the specified address */    ICGTRM = *(unsigned char*)0xFFBE;  /* Initialize ICGTRM register from a non volatile memory */  }  while(!ICGS1_LOCK) {                 /* Wait */  }

 

 

 

If I am not misstaken, this gets me prescaler P = 1, Multiplier N = 8 and Divider R = 1

 

According to the reference manual, page 186, Eqn 10-5, this gets me a bus clock of

fICGOUT = (fIRG / 7) * P * N / R

P = 1, N = 8, R = 1, fIRG = 226.5 kHz

thus

flCGOUT = 226.5kHz / 7 * 8 = 258kHz

 

In fact, I can verify this bus frequency by a simple software loop that toggles a pin. Obivously it's 1/32 of what I want.

 

So, did I setup anything wrong in PE here or is it a PE problem? Because I am not sure what steps to take, I wouldnt want to go without PE on this project, since it sets up a whole bunch of other stuff for me, but I can not manually correct the generated code of course, since it would get overwritten all the time.

Would it be a safe alternative to just setup the clock "manually" after the call to PE_low_level_init(); then?

 

I do hope though that I am just overlooking something obvious in the setup.

 

Regards,

 Sven

Outcomes