SAMO6
Newbie level 5
I am new to serial communication.I am trying to send a string(characters) on RS232 to hyperterminal software. I have tried simulation in proteus but, it is not working at all.
Can you tell me what corrections should I do in my code? What are the wrong things in my code?
Plz, Help.
I am using PIC18F4550 microcontroller, MPLAB X IDE, XC8 compiler, 20MHz Crystal Frequency.
Below is my code and screenshot of proteus simulation:
Can you tell me what corrections should I do in my code? What are the wrong things in my code?
Plz, Help.
I am using PIC18F4550 microcontroller, MPLAB X IDE, XC8 compiler, 20MHz Crystal Frequency.
Below is my code and screenshot of proteus simulation:
Code:
#include<p18F4550.h>
void delay()
{
unsigned int i;
for(i=0;i<=30000;i++);
}
void main(void)
{
unsigned char data,i;
unsigned char s[]={"Hello"};
TRISCbits.RC6 = 0; //Configure TX pin set as output (RC6)
SPBRG = 0X20; // Set Baud Rate (X value)
TXSTA = 0b00100000; //Asynchronous 8-bit; Transmit enabled; Low speed baud rate select
RCSTA = 0b10010000; // Enable Serial Port and continuous receive enable pin
for(i=0;i<15;i++)
{
data=s[i];
TXREG =data ; // Data to be transmitted is loaded in TXREG register
while(PIR1bits.TXIF == 0); //Wait while transmit register is empty
delay();
}
}