金牌会员
 
- 积分
- 1330
- 金钱
- 1330
- 注册时间
- 2020-1-10
- 在线时间
- 131 小时
|
100金钱
探索者的485例程功能是:检测按键状态,按键按下后发送数据。我将程序作了修改,想要实现的功能是:接收串口调试助手的数据,然后将此数据发送出去。现在开发板一直接收不到,各位大佬帮忙看下我的程序哪里有问题:
int main(void)
{
u8 key;
u8 i=0,t=0;
u8 cnt=0;
u8 rs485buf[5];
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置系统中断优先级分组2
delay_init(168); //初始化延时函数
uart_init(9600); //初始化串口波特率为9600
RS485_Init(9600); //初始化RS485串口2
while(1)
{
RS485_Receive_Data(rs485buf,&key);
if(key)//接收到有数据
{
if(key>5)key=5;//最大是5个数据.
for(i=0;i<key;i++)RS485_Send_Data(rs485buf,5);//发送5个字节 ; //显示数据
}
}
}
单纯的发送功能已经实现了
|
|