39 lines
739 B
C
39 lines
739 B
C
// sender
|
||
#include "STC15F2K60S2.H"
|
||
#include "sys.h"
|
||
#include "uart2.h"
|
||
|
||
code unsigned long SysClock = 11059200; //必须。定义系统工作时钟频率(Hz),用户必须修改成与实际工作频率(下载时选择的)一致
|
||
char num[5]={0x01,0x03,0x05,0x07,0x09};
|
||
int countdown=10;
|
||
|
||
void sendData()
|
||
{
|
||
int i;
|
||
if(countdown)
|
||
{
|
||
countdown--;
|
||
}
|
||
countdown=10;
|
||
Uart2Print(num,5);
|
||
for(i=0;i<5;i++)
|
||
{
|
||
num[i]++;
|
||
if(num[i]>0x09)
|
||
{
|
||
num[i]=0x01;
|
||
}
|
||
}
|
||
}
|
||
|
||
void main()
|
||
{
|
||
Uart2Init(1200,Uart2Usedfor485); //初始化串口2,波特率为2400
|
||
SetEventCallBack(enumEventSys1S,sendData);
|
||
MySTC_Init();
|
||
while (1)
|
||
{
|
||
MySTC_OS();
|
||
}
|
||
}
|