找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 8458|回复: 7
收起左侧

STC11F04E单片机RS485串口通信源程序 带按键输入,LED指示的开发板资料

  [复制链接]
ID:284341 发表于 2018-11-18 11:06 | 显示全部楼层 |阅读模式
STC11F04E单片机精简开发板 串口通信 按键输入 485通信LED指示
主要芯片:STC11F04E单片机
工作电压:直流5~15伏(电源选择5V和大于5V两种模式)
特点:
         1、具有电源指示;
         2、所有I/O口已引出;
         3、可以实现与电脑串口通信;
         4、可以实现双串口通讯;(MAX232和MAX485双串口通讯,MAX232也是下载程序口)
         5、具有上电复位和手动复位;
         6、电源防反接二极管;
         7、支持STC串口下载;
         8、双串口通讯(注:下载程序只能使用MAX232口);
         9、四路路LED灯(可用上位机控制,);
        10、可端子接线供电、可排针引电;
       11、7805供电,输入电压范围宽

五、提供相关软件、资料、原理图
STC11F104E开发板产品使用手册464.png STC11F104E开发板产品使用手册516.png STC11F104E开发板产品使用手册517.png STC11F104E开发板产品使用手册520.png

单片机RS485源程序如下:
  1. /********************************************************************
  2.                             汇诚科技

  3. 实现功能:此版配套测试程序
  4. 使用芯片:STC11F104E
  5. 晶振:11.0592MHZ
  6. 波特率:9600
  7. 编译环境:Keil
  8. 作者:zhangxinchunleo     
  9. /********************************************************************
  10. 上电后,发送数据 STC10/11xx\r\nUart Test !\r\n
  11. ********************************************************************/

  12. #include "reg51.h"
  13. #include "intrins.h"

  14. typedef unsigned char BYTE;
  15. typedef unsigned int WORD;

  16. #define FOSC 11059200L      //System frequency
  17. #define BAUD 9600           //UART baudrate

  18. /*Define UART parity mode*/
  19. #define NONE_PARITY     0   //None parity
  20. #define ODD_PARITY      1   //Odd parity
  21. #define EVEN_PARITY     2   //Even parity
  22. #define MARK_PARITY     3   //Mark parity
  23. #define SPACE_PARITY    4   //Space parity

  24. #define PARITYBIT EVEN_PARITY   //Testing even parity

  25. sfr AUXR1 = 0xA2;
  26. #define UART_P1 0x80        //(AUXR1.7) switch RXD/TXD from P3.0/P3.1 to P1.6/P1.7

  27. sbit bit9 = P2^2;           //P2.2 show UART data bit9
  28. bit busy;

  29. void SendData(BYTE dat);
  30. void SendString(char *s);

  31. void main()
  32. {
  33.     AUXR1 |= UART_P1;       //switch RXD/TXD from P3.0/P3.1 to P1.6/P1.7

  34. #if (PARITYBIT == NONE_PARITY)
  35.     SCON = 0x50;            //8-bit variable UART
  36. #elif (PARITYBIT == ODD_PARITY) || (PARITYBIT == EVEN_PARITY) || (PARITYBIT == MARK_PARITY)
  37.     SCON = 0xda;            //9-bit variable UART, parity bit initial to 1
  38. #elif (PARITYBIT == SPACE_PARITY)
  39.     SCON = 0xd2;            //9-bit variable UART, parity bit initial to 0
  40. #endif

  41.     TMOD = 0x20;            //Set Timer1 as 8-bit auto reload mode
  42.     TH1 = TL1 = -(FOSC/12/32/BAUD); //Set auto-reload vaule
  43.     TR1 = 1;                //Timer1 start run
  44.     ES = 1;                 //Enable UART interrupt
  45.     EA = 1;                 //Open master interrupt switch

  46.     SendString("STC10/11xx\r\nUart Test !\r\n");
  47.     while(1);
  48. }

  49. /*----------------------------
  50. UART interrupt service routine
  51. ----------------------------*/
  52. void Uart_Isr() interrupt 4 using 1
  53. {
  54.     if (RI)
  55.     {
  56.         RI = 0;             //Clear receive interrupt flag
  57.         P0 = SBUF;          //P0 show UART data
  58.         bit9 = RB8;         //P2.2 show parity bit
  59.     }
  60.     if (TI)
  61.     {
  62.         TI = 0;             //Clear transmit interrupt flag
  63.         busy = 0;           //Clear transmit busy flag
  64.     }
  65. }

  66. /*----------------------------
  67. Send a byte data to UART
  68. Input: dat (data to be sent)
  69. Output:None
  70. ----------------------------*/
  71. void SendData(BYTE dat)
  72. {
  73.     while (busy);           //Wait for the completion of the previous data is sent
  74.     ACC = dat;              //Calculate the even parity bit P (PSW.0)
  75.     if (P)                  //Set the parity bit according to P
  76.     {
  77. #if (PARITYBIT == ODD_PARITY)
  78.         TB8 = 0;            //Set parity bit to 0
  79. #elif (PARITYBIT == EVEN_PARITY)
  80.         TB8 = 1;            //Set parity bit to 1
  81. #endif
  82.     }
  83.     else
  84.     {
  85. #if (PARITYBIT == ODD_PARITY)
  86.         TB8 = 1;            //Set parity bit to 1
  87. #elif (PARITYBIT == EVEN_PARITY)
  88.         TB8 = 0;            //Set parity bit to 0
  89. #endif
  90.     }
  91.     busy = 1;
  92.     SBUF = ACC;             //Send data to UART buffer
  93. }

  94. /*----------------------------
  95. Send a string to UART
  96. Input: s (address of string)
  97. Output:None
  98. ----------------------------*/
  99. void SendString(char *s)
  100. {
  101.     while (*s)              //Check the end of the string
  102.     {
  103.         SendData(*s++);     //Send current char and increment string ptr
  104.     }
  105. }

  106.         
  107. /********************************************************************
  108.                               结束
  109. *********************************************************************/
复制代码

所有资料51hei提供下载:

485测试程序.rar

31.9 KB, 下载次数: 81, 下载积分: 黑币 -5

STC11F104E开发板产品使用手册.doc

2.45 MB, 下载次数: 45, 下载积分: 黑币 -5

STC11F104E开发板原理图.doc

96 KB, 下载次数: 41, 下载积分: 黑币 -5

STC11FXX开发板原理图及PCB图.pdf

542.51 KB, 下载次数: 57, 下载积分: 黑币 -5

该板配套测试程序.rar

32.14 KB, 下载次数: 59, 下载积分: 黑币 -5

回复

使用道具 举报

ID:461314 发表于 2019-1-3 20:52 来自手机 | 显示全部楼层
厉害了!!!
回复

使用道具 举报

ID:521447 发表于 2019-4-25 16:11 | 显示全部楼层
这个可以玩一下,手头刚好有个这片子
回复

使用道具 举报

ID:79544 发表于 2019-5-13 15:38 | 显示全部楼层
感谢楼主分享,学了啦
回复

使用道具 举报

ID:142743 发表于 2019-6-1 18:01 | 显示全部楼层
楼主厉害
回复

使用道具 举报

ID:692689 发表于 2020-5-17 11:08 | 显示全部楼层
楼主 原理图里面的power1是什么芯片啊
回复

使用道具 举报

ID:854435 发表于 2020-12-4 15:40 | 显示全部楼层
这个可以玩一下,手头刚好有个这片子
回复

使用道具 举报

ID:1001248 发表于 2022-1-11 09:56 | 显示全部楼层
这个看起来是可以作为一个小的开发板
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表