485通信只能发不能收

2019-07-21 01:49发布

把串口1接收到的收据放到串口2 的接收缓存区让让485通过串口2发送出去,但是我的程序只能接收到串口1发送过来的数据,不能通过485发送出去,不知道哪里有问题 [mw_shl_code=c,true]#include "sys.h" #include "usart.h" #include "delay.h" #include "key.h" #include "led.h" #include "rs485.h" #include "lcd.h" #include "beep.h" int main(void) { u8 t; u8 rxlen; u8 rs485buf[64]; u8 times=0; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); uart_init(115200); delay_init(168); KEY_Init(); LED_Init(); RS485_Init(9600); LCD_Init(); POINT_COLOR=RED; LCD_ShowString(30,50,200,16,16,"Explorer STM32F4"); LCD_ShowString(30,70,200,16,16,"RS485 TEST"); LCD_ShowString(30,90,200,16,16,"ATOM@ALIENTEK"); LCD_ShowString(30,110,200,16,16,"2015/8/25"); POINT_COLOR=BLUE; LCD_ShowString(30,170,200,16,16,"Send Data:"); LCD_ShowString(30,210,200,16,16,"Receive Data:"); while(1) { delay_ms(2); if(USART_RX_STA&0x8000) { rxlen=USART_RX_STA&0x3fff; for(t=0;t<rxlen;t++) { rs485buf[t]=USART_RX_BUF[t]; LCD_ShowxNum(30+t*32,190,rs485buf[t],3,16,0X80); } RS485_Send_Data(rs485buf,rxlen); USART_RX_STA=0; } else { times++; if(times%200==0)printf("请输入数据 "); if(times%30==0)LED0=!LED0; delay_ms(10); } } } [/mw_shl_code]


友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。