// Chapter 1 9S12C32 C programs // Jonathan W. Valvano, 2/07/07 // This software accompanies the book, // Embedded Microcomputer Systems: Real Time Interfacing, Second Edition // published by Thomson Engineering, 2006 void PLL_Init(void){ SYNR = 0x02; REFDV = 0x00; // PLLCLK = 2*OSCCLK*(SYNR+1)/(REFDV+1) CLKSEL = 0x00; PLLCTL = 0xD1; while((CRGFLG&0x08) == 0){ // Wait for PLLCLK to stabilize. } CLKSEL_PLLSEL = 1; // Switch to PLL clock } // Program 1.1. MC9S12C32 program that increases the 4MHz E clock to 24MHz. // MC9S12C32 #define PTT *(unsigned char volatile *)(0x0240) #define PTIT *(unsigned char volatile *)(0x0241) #define DDRT *(unsigned char volatile *)(0x0242) // Program 1.3. C definitions of an I/O port. // MC9S12C32 DDRT = 0x0F; //Program 1.5. C software that initializes pins 7-4 to input and pins 3-0 to output. // MC9S12C32 void main(void){// make PT3-0 DDRT = 0x0F; // outputs while(1){ PTT = 5; // 0101 PTT = 6; // 0110 PTT = 10; // 1010 PTT = 9; // 1001 } } //Program 1.7. C software for the LED output system.