飞思卡尔 xs128 的输入捕捉程序
#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#include <stdio.h>
void setbusclock(void)
{
CLKSEL="0X00"; // disengage PLL to system
PLLCTL_PLLON=1; // turn on PLL
SYNR="0x00" | 0x01;
_asm(nop); // BUS CLOCK="16M"
_asm(nop);
while(!(CRGFLG_LOCK==1)); //when pll is steady ,then use it;
CLKSEL_PLLSEL =1; //engage PLL to system;
}
//-----------------------------------------------------
void SCI_Init(void)
{
SCI0CR2=0x2c; //enable Receive Full Interrupt,RX enable,Tx enable
SCI0BDH=0x00; //busclk 8MHz,19200bps,SCI0BDL=0x1a
SCI0BDL=0x68; //SCI0BDL=busclk/(16*SCI0BDL)
//busclk 16MHz, 9600bps,SCI0BDL=0x68
}
void uart_putchar(unsigned char ch)
{
if (ch == '')
{
while(!(SCI0SR1&0x80)) ;
SCI0DRL= 0x0d; //output'CR'
return;
}
while(!(SCI0SR1&0x80)) ; //keep waiting when not empty
SCI0DRL=ch;
}
void putstr(char ch[])
{
unsigned char ptr="0";