#include /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#include "MC9S08AW32.h"
/*************************************************************************/
/**************************define function********************************/
void InitICG();
void InitSCI0();
void InitGPIO();
__interrupt void Vsci0rx_isr(void);
void SCIProcess();
void TransSCI(byte ReceivedByte);
/*************************************************************************/
/**************************define parameter********************************/
byte ReceivedByte;
int IsSCI;
void InitSCI0()
{
SCI1C1=0x00;
SCI1C2=0x2C;
SCI1C3=0x00;
SCI1BDH=0x00;
SCI1BDL=0x1a; //baud=9600;
}
__interrupt void Vsci0rx_isr(void)
{
IsSCI=1;
if(SCI1S1_RDRF)
ReceivedByte=SCI1D;//存缓冲区内容
ReceivedByte+=1;
}
void TransSCI(byte TransByte) //发送一个字节
{
while(SCI1S1_TDRE==0);
SCI1D=TransByte;
}
/*********************main()*****************************************/
void main(void)
{
IsSCI = 0;
InitSCI0();
EnableInterrupts;
for(;;)
{
__RESET_WATCHDOG();
if(IsSCI==1)
{
TransSCI(ReceivedByte);
IsSCI=0;
}
}
}
使用8M晶振,未加PLL,串口只能读数据,不能发送数据 |