- UID
- 170441
- 性别
- 男
|
我用串口调试助手想调试S12DG128模块的SCI部分,一直接收不到数据,忘版主帮忙看看程序~~~~~~~
#include /* common defines and macros */
#include /* derivative information */
#define U_char unsigned char
#define uint unsigned int
unsigned char count3=0,ch;
#define INBUF_LEN 4
unsigned char flag=0 ;
unsigned char inbuf1[INBUF_LEN];
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
void SCI0Init(void) {
SCI0BDL = 52;
SCI0CR2 = 0x2C;
}
void send_string_com(U_char *address,U_char n)
{
U_char i;
SCI0CR2_RE=0; //接收禁止
SCI0CR2_TE=1; //发送允许
for(i=0;i=8;i++) {
while(!SCI0SR1_TC);
while(!SCI0SR1_TDRE);
SCI0DRL=*address;
// delay(1);
}
SCI0CR2_TE=0; //发送禁止
}
#pragma CODE_SEG __NEAR_SEG NON_BANKED
interrupt 20 void SCI0_interrupt(void)
{
while(SCI0SR1_RDRF)
{
inbuf1[count3]=ch;
count3++;
if( (count3==(INBUF_LEN-1)))
{
flag=1;
}
}
}
#pragma CODE_SEG DEFAULT
void main(void)
{
SCI0Init();
// init_io();
EnableInterrupts;
for(;;)
{
if(flag) //如果取数标志位已置位,就将读到的数从串口发出
{
flag=0; //取数标志位清零
send_string_com(inbuf1,INBUF_LEN);
}
} /* wait forever */
}
|
|