Modbus485通讯,把部分IO口组合在一起做一组,反复试了多次,在网上根据网上资料,还有在本网的一些帖子,都没能完成,请大佬指导下该怎么办啊,非常感谢。
单片机源程序如下:
- /*定义不同引脚一组*/
- #ifndef _USER_IO_H__
- #define _USER_IO_H__
- #include "STC8H.h"
- #include <intrins.h>
- //u8 data IONum[]=" ";//
- sbit IN7 = P3^5;//
- sbit IN6 = P3^6;
- sbit IN5 = P3^7;
- sbit IN4 = P2^0;
- sbit IN3 = P2^1;
- sbit IN2 = P2^2;
- sbit IN1 = P2^3;
- sbit IN0 = P2^4;
- sbit OT7 = P5^3;
- sbit OT6 = P1^6;
- sbit OT5 = P4^7;
- sbit OT4 = P0^5;
- sbit OT3 = P0^6;
- sbit OT2 = P0^7;
- sbit OT1 = P1^0;
- sbit OT0 = P4^3;
- extern unsigned char daIN;
- extern unsigned char daOT;
- extern void IOIN_Data(daIN);//输入IO定义IOIN_Data(u8 daIN)
- extern void IOOT_Data(daOT);//输出IO定义
- #endif
复制代码
- void display1()
- {
- unsigned char h,z;
- h=12;
- delayms1(100);
- daOT = 0x80;
- // OT7 = OK;
- delayms1(100);
- daOT = 0x00;
- // OT7 = OFF;
- }
复制代码
|