#include<pic.h>
#include<htc.h>
#include<conio.h>
#include<stdio.h>
void init_rs232();
void main()
{
TRISE = 0x08;
TRISB = 0x00;
init_rs232();
while(1){
if(RE3==0){
RB0=1;
if(TRMT)
TXREG = 0x41; //sending 'A'
}
else{
RB0=0;
if(TRMT)
TXREG = 0x70; //sending 'p'
}
}
}
void init_rs232()
{
BRGH = 1;
BRG16 = 0;
SPBRG = 51; /* set baud rate: Fosc=8Mhz, 16, BR=9600 */
TX9 = 0; /* ninebits?1:0,,,8- or 9-bit transmission */
SYNC = 0; /* asynchronous */
SPEN = 1; /* enable serial port pins */
TXEN = 1; /* enable the transmitter & (automatically)TXIF=1 */
CREN = 1; /* enable reception */
SREN = 0; /* no effect */
TXIE = 0; /* disable tx interrupts */
RCIE = 0; /* disable rx interrupts */
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?