金牌会员
- 积分
- 1733
- 威望
- 304
- 贡献
- 1391
- 兑换币
- 4
- 注册时间
- 2009-3-29
- 在线时间
- 19 小时
|
1贡献
这个程序为什么不能正确收发数据啊?请大家帮我看看
#include <hidef.h> /* common defines and macros */
#include <MC9S12XS128.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12xs128"
#include "main_asm.h" /* interface to the assembly module */
#define uchar unsigned char
#define uint unsigned int
uchar R_date,R_flag;
uchar T_date,T_flag;
uint numeric;
void PLL(void);
void SCI_INIT(void);
void NORMAL_IO_INIT(void);
uchar SCI_R(void);
void delay(uint z);
void SCI_T(uchar T_date);
void SCI_INIT(void)
{
SCI0BD=312.5;
SCI0CR1=0X00;
SCI0CR2=0B00001100;
SCI0CR2_RIE = 1;
SCI0CR2_TIE = 1;
}
void PLL(void)//48MHz
{
CLKSEL=0X00;
PLLCTL_PLLON =1;
SYNR = 0xC0|0X05;
REFDV= 0xC0|0x01; // PLLCLK =2*OSCCLK*(SYNR + 1)/(REFDV + 1)
POSTDIV=0X00;
_asm(nop);
_asm(nop);
while(CRGFLG_LOCK == 0);
CLKSEL_PLLSEL = 1;
}
void NORMAL_IO_INIT()
{
DDRB=0XFF;
PORTB=0Xf0;
}
void delay(uint z)
{
uint i,j;
for(i=0;i<z;i++);
for(j=0;j<2770;j++);
}
uchar SCI_R(void)
{
while(SCI0SR1_RDRF)
{
SCI0SR1_RDRF=1;
return SCI0DRL;
}
}
void SCI_T(uchar T_date)
{
SCI0SR1_TC=1;
SCI0DRL=T_date;
delay(10);
}
void main(void)
{
PLL();
NORMAL_IO_INIT();
SCI_INIT();
EnableInterrupts;
asm_main(); /* call the assembly function */
delay(20);
for(;;)
{
if(SCI0SR1_RDRF==1)
{
SCI0SR1_RDRF=0;
numeric=SCI0DRL;
PORTB=numeric;
SCI0DRL=numeric;
}
}
} |
|