标题: STM32F103c8t6读取rs485设备数据 源程序 [打印本页]

作者: 1183953327    时间: 2020-5-8 10:29
标题: STM32F103c8t6读取rs485设备数据 源程序
网上使用stm32读取485设备的教程少之又少,该代码使用战舰库函数,修改好问讯485设备地址以及连好线就可以读取
  1. #include "led.h"
  2. #include "delay.h"
  3. #include "key.h"
  4. #include "sys.h"
  5. #include "lcd.h"
  6. #include "usart.h"         
  7. #include "rs485.h"


  8.                                         
  9. int main(void)
  10. {         
  11.         delay_init();                     //延时函数初始化          
  12.         NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断优先级分组为组2:2位抢占优先级,2位响应优先级
  13.         uart_init(9600);                 //串口初始化为115200
  14.         LED_Init();                                  //初始化与LED连接的硬件接口
  15. //        LCD_Init();                                   //初始化LCD        
  16.         KEY_Init();                                //按键初始化                          
  17.         RS485_Init(9600);        //初始化RS485
  18.         printf("测试中。。。。");
  19.   
  20.         while(1)
  21.         {
  22.                 delay_ms(1);
  23.                 Rs485_sensor_work();       //不断打印出 传感器的值
  24.                 delay_ms(1);
  25.           
  26.         }
  27. }
复制代码

全部程序51hei下载地址:
读取 485温湿度.7z (222.31 KB, 下载次数: 206)

作者: zcl777    时间: 2020-6-24 15:23
好东西看,看看,希望好使
作者: 51heie    时间: 2023-3-6 16:36
在哪修改从机地址啊 求助




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1