









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










⇒ ⇒ ⇒ ⇒ ⇒
⇒ ⇒ ⇒
//------------------------------------------------------------------------------------------------- // SYSCLK_Init //------------------------------------------------------------------------------------------------- // // Initialize the system clock to use a 22.1184MHz crystal as its clock source // void SYSCLK_INIT(void) { int i; char SFRPAGE_SAVE = SFRPAGE; // Save Current SFR page SFRPAGE = CONFIG_PAGE; OSCXCN = 0x67; // Start external oscillator with 22.1184MHz crystal for(i=0; i < 256; i++); // Wait for the oscillator to start up while(!(OSCXCN & 0x80)); CLKSEL = 0x01; OSCICN = 0x00; SFRPAGE = CONFIG_PAGE; PLL0CN = 0x04; SFRPAGE = LEGACY_PAGE; FLSCL = 0x10; SFRPAGE = CONFIG_PAGE; PLL0CN |= 0x01; PLL0DIV = 0x04; PLL0FLT = 0x01; PLL0MUL = 0x09; for(i=0; i < 256; i++); PLL0CN |= 0x02; while(!(PLL0CN & 0x10)); CLKSEL = 0x02; SFRPAGE = SFRPAGE_SAVE; // Restore SFR page } //------------------------------------------------------------------------------------------------- // PORT_Init //------------------------------------------------------------------------------------------------- // // Configure the Crossbar and GPIO ports // void PORT_INIT(void) { char SFRPAGE_SAVE = SFRPAGE; // Save Current SFR page SFRPAGE = CONFIG_PAGE; XBR0 = 0x04; // Enable UART XBR1 = 0x00; XBR2 = 0x40; // Enable Crossbar and weak pull-up P0MDOUT |= 0x01; // Set TX0 pin to push-pull SFRPAGE = SFRPAGE_SAVE; // Restore SFR page } //------------------------------------------------------------------------------------------------- // UART)_Init //------------------------------------------------------------------------------------------------- // // Configure the UART0 using Timer1, for
SFRPAGE = UART0_PAGE; TI0 = 1; // Indicate TX0 ready SFRPAGE = SFRPAGE_SAVE; // Restore SFR page }