#include /* derivative information */#include "pll.h" /* defines _BUSCLOCK, sets bus frequency to _BUSCLOCK MHz */#include "sci0.h" /* support for SCI0 */#include "sci1.h" /* support for SCI1 */void main(void) {char myString0[32];/* set system clock frequency to _BUSCLOCK MHz (24 or 4) */PLL_Init();/* initialise serial communication interface SCI0 */SCI0_Init(BAUD_9600);/* initialise serial communication interface SCI1 */SCI1_Init(BAUD_19200);SCI1_OutString("Enter string\n\r");SCI1_InString(myString0, 10);SCI0_OutString("\n\rYou have entered: ");SCI0_OutString(myString0);SCI0_OutString("\n\r\n\r");}
#include /* derivative information */#include "pll.h" /* defines _BUSCLOCK, sets bus frequency to _BUSCLOCK MHz */#include "sci0.h" /* support for SCI0 */#include "sci1.h" /* support for SCI1 */void main(void) {char myString0[32];/* set system clock frequency to _BUSCLOCK MHz (24 or 4) */PLL_Init();/* initialise serial communication interface SCI0 */SCI0_Init(BAUD_9600);/* initialise serial communication interface SCI1 */SCI1_Init(BAUD_19200);SCI1_OutString("1OR\r");SCI1_OutString("1VE—\r");SCI1_InString(myString0, 10);SCI0_OutString("\n\rYou have entered: ");SCI0_OutString(myString0);SCI0_OutString("\n\r\n\r");}
// filename *************** sci1.c ******************************// Simple I/O routines to 9S12C32 serial port// Jonathan W. Valvano 1/29/04// Copyright 2004 by Jonathan W. Valvano, valvano@mail.utexas.edu// You may use, edit, run or distribute this file// as long as the above copyright notice remains// Modified by EE345L students Charlie Gough && Matt Hawk// Modified by EE345M students Agustinus Darmawan + Mingjie Qiu//// adapted to the Dragon12 board using SCI1 -- fw-07-04// allows for 24 MHz bus (PLL) and 4 MHz bus (no PLL) -- fw-07-04#include /* derivative information */#include "sci1.h"#include "pll.h" /* macro _SYSCLOCK */#define RDRF 0x20 // Receive Data Register Full Bit#define TDRE 0x80 // Transmit Data Register Empty Bit//-------------------------SCI1_Init------------------------// Initialize Serial port SCI1// Input: baudRate is tha baud rate in bits/secvoid SCI1_Init(unsigned short baudRate) {SCI1BDH=0;SCI1BDL=78;SCI1CR1 = 0;SCI1CR2 = 0x0C;}//-------------------------SCI1_InChar------------------------// Wait for new serial port input, busy-waiting synchronization// Output: ASCII code for key typedchar SCI1_InChar(void) {while((SCI1SR1 & RDRF) == 0){};return(SCI1DRL);}//-------------------------SCI1_OutChar------------------------// Wait for buffer to be empty, output 8-bit to serial port// busy-waiting synchronization// Input: 8-bit data to be transferredvoid SCI1_OutChar(char data) {while((SCI1SR1 & TDRE) == 0){};SCI1DRL = data;}
Message Edited by Alban on 06-06-2006 01:02 PM
Message Edited by imajeff on 06-02-2006 02:07 PM
Message Edited by rocco on 06-02-2006 02:38 PM