Michael Stahl

MC9S08QE128 internal clock

Discussion created by Michael Stahl on Oct 8, 2007
Latest reply on Oct 8, 2007 by Ake Webjorn
Hello,
last week I got the new chip (MC9S08WE128). The datasheet says that the internal clock can be configured up to 20MHz.

So I set up the ICS and toggle a port but I can only measure 2MHz. Why?

Has anybody a explanation?


#include <hidef.h>                        /* for EnableInterrupts macro */
#include "derivative.h"                   /* include peripheral declarations */
#include "DEMOQE128_Quick_Start.h"        /* include variable declarations */

#define clrSetReg8Bits(RegName, ClrMask, SetMask)  (RegName = (RegName & (~(byte)(ClrMask))) | (byte)(SetMask))
#define setReg8(RegName, val)                      (RegName = (byte)(val))


void InitSystems() {
 
  SOPT1  = 0x23;                          // Disable COP,RSTO, enable STOP,BKGD,RESET
  SOPT2  = 0x00;                          // SPI1 on PTB2/3/4/5, IIC1 on PTA2/3
  SPMSC1 = 0x00;                          // Disable LVD
  SPMSC2 = 0x00;                          // Disable power-down modes
  SPMSC3 = 0x00;                          // Disable LVWIE, low trip points
  SCGC1  = 0xFF;                          // Enable bus clock to peripherals
  SCGC2  = 0xFF;                          // Enable bus clock to peripherals
  
  /*  System clock initialization */
  /* ICSC1: CLKS=0,RDIV=0,IREFS=1,IRCLKEN=1,IREFSTEN=0 */
  setReg8(ICSC1, 0x06);                /* Initialization of the ICS control register 1 */
  /* ICSC2: BDIV=0,RANGE=0,HGO=0,LP=0,EREFS=0,ERCLKEN=0,EREFSTEN=0 */
  setReg8(ICSC2, 0x00);                /* Initialization of the ICS control register 2 */
  while(!ICSSC_IREFST) {               /* Wait until the source of reference clock is internal clock */
  }
  /* ICSSC: DRST_DRS=2,DMX32=1 */
  ICSSC = 0xA1;
} // end InitSystems


/************************
   Main Program Loop
************************/
void main(void) {

 
  InitSystems();

  PTCD_PTCD0   = 0;
  PTCDD_PTCDD0 = 1;                  // Turn ON PTC0 LED

  while(1)
  {
        PTCTOG_PTCTOG0   = 1;
  }
}


Best regards

Michael

Outcomes