Serial com sending

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
#include <reg66x.h>
void sinit(void); //serial init function
void delay(unsigned int t); //delay function
sbit UP=P2^1;
void main()
{int i=0;
char code w[20]="EMB2 serial test ";
sinit(); //init serial communication
while(1)
{if (UP==0){
for (i=0;i<=17;i++){
S0BUF = w[i];
while(!TI);
TI = 0;
delay(30000); //wait for a second
}}
}}
void sinit(void) //serial init fuction
{ TMOD = 0x20;
S0CON = 0x40;
TH1 = 0xFA;
TL1 = 0xFA;
TR1 = 1;
}
void delay(unsigned int t)
{unsigned int i;
for (i=0;i<t;i++);
}