azarutz
Member level 2
- Joined
- Mar 4, 2012
- Messages
- 42
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,288
- Location
- India
- Activity points
- 1,579
hi i wrote program for pic uart in hitech-c and i am trying to simulate it in proteus and i need help .I used LCD to display data which i typed in virtual terminal is it works . what is virtual terminal in proteus . is it used to send and receive data from microcontroller .
Code:
#include<htc.h>
#include"lcd.h"
void pic_init();
void uart_init();
void transmit(char);
int data , rdata;
void interrupt ISR(void)
{
if(RCIF==1)
{
if(OERR)
{
CREN=0;
CREN=1;
}
rdata=RCREG;
}
}
void main ()
{
pic_init();
uart_init();
lcd_init();
transmit('H');
while(1)
{
printf("recived data=%c" ,rdata);
}
}
void pic_init()
{
RC6=0;
RC7=1;
PORTD=0x00;
PORTB=0xf8;
GIE=1;
PEIE=1;
TXIE=1;
RCIE=1;
}
void uart_init()
{
TX9=0;
TXEN=1;
SYNC=0;
BRGH=1;
SPEN=1;
RX9=0;
CREN=1;
SPBRG = 129;
}
void transmit(char data)
{
TXREG=data;
while(!TRMT);
}