智能车制作
标题:
xs128 串口调试问题
[打印本页]
作者:
happy1990now
时间:
2012-2-16 19:04
标题:
xs128 串口调试问题
为了便于小车,调试,写了下串口调试程序,现在遇到一个问题,就是通过 串口调试助手 电脑能接收到XS128发过来的信息,但电脑发向xs128的信息,xs128确接受不到,写了一个简单判断的程序,发现单片机没有收到数据,各位麻烦帮忙看看
代码如下:
//初始化SCI以及相应函数
#include "main.h"
void UART_Init (void)
{
//printf("UART_Init\n");
SCI0CR2=0x2c; //enable Receive Full Interrupt,RX enable,Tx enable
SCI0BDH=0x01; //busclk 8MHz,19200bps,SCI0BDL=0x1a
SCI0BDL=0xa0; //SCI0BDL=busclk/(16*SCI0BDL)
//busclk 32MHz, 9600bps,SCI0BDL=0xD0
//115200 bps SCI0BDL=0x11
} // 64M 9600 SCI0BDH=0x01; SCI0BDL=0xA0;
void uart_putchar ( unsigned char c)
{
while(!(SCI0SR1&0x80)) ; //keep waiting when not empty
SCI0DRL=c;
}
void uart_putstr(char ch[])
{
unsigned char ptr=0;
while(ch[ptr]){
uart_putchar((unsigned char)ch[ptr++]);
}
}
unsigned char uart_getchar(void)
{
// printf("uart_getchar\n");
byte res=0;
while(!(SCI0SR1&0x80)) ; //keep waiting when not empty
return (SCI0DRL);
}
复制代码
测试程序:
void main(void)
{
DDRB = 0xff;
PORTB = 0xff;
/*
DDRA = 0x00;
PUCR_PUPAE = 1;
*/
DeviceInit();
EnableInterrupts;
while(1)
{
// if(TimeCount[1]==0) { OutPut_Data();;TimeCount[1] = 3000;}
//if(TimeCount[0]==0) { kalman_update();Motor_Regler();TimeCount[0] = 800;}
if (uart_getchar() == 'c')
uart_putstr("Usart Is Working!");
}
}
复制代码
作者:
Solemn胜威
时间:
2012-3-6 15:49
能把你这个整个的NRF2401发给我吗?谢谢咯,我的 邮箱是
1174063087@qq.com
作者:
hhf1100
时间:
2012-3-12 17:21
能给我发一个吗???
459067481@qq.com
,谢谢
作者:
ilyht
时间:
2012-5-26 17:24
Me too!!!
作者:
mxj1005071012
时间:
2013-1-3 14:36
我也需要啊 我的串口助手接不到数据 想确定是硬件问题还是软见问题
891876745@qq.com
欢迎光临 智能车制作 (http://dns.znczz.com/)
Powered by Discuz! X3.2