Skip to content

Instantly share code, notes, and snippets.

@MaciejLisCK
Last active May 20, 2016 13:55
Show Gist options
  • Save MaciejLisCK/faaf4a724c469131e1aed7695e27964e to your computer and use it in GitHub Desktop.
Save MaciejLisCK/faaf4a724c469131e1aed7695e27964e to your computer and use it in GitHub Desktop.
Microcontroller Serial in Keil, RS232, Serial Communication, C, avr, atmel
#include <REGX52.H>
void Serial() interrupt 4
{
if(RI == 1)
{
P1 = SBUF;
RI = 0;
}
}
main()
{
SCON = 0x50;
TH2 = RCAP2H = 0xFF;
TL2 = RCAP2L = 0xDC;
T2CON = 0x34;
ES = 1;
EA = 1;
while(1)
;
}
#include <REGX52.H>
unsigned char i = 0;
void main()
{
SCON = 0x50;
TH2 = RCAP2H = 0xFF;
TL2 = RCAP2L = 0xDC;
T2CON = 0x34;
ES = 1;
while(1)
{
TI = 0;
P1 = i;
SBUF = i;
while(TI==0)
{;}
i++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment