Hi,
I am trying to do a small program to get the USART to work. I want to write the letter "A" out on the RS232 port. I have downloaded a sample hex file and loaded into the PIC to test the RS-232 comms to my pc. All is working except my version of code. I am getting funny asterix symbols out the comms port.
Have I left something out of the code. I have set up the registers as per the datasheet and I am only transmitting at the moment.
Code:
#include <p18cxxx.h>
void init_usart(void) // Initialise the USART
{
TXSTA=0x24; // Asynch,8bits,tx enb
RCSTA=0x90;
SPBRG=0x12; // BaudRate=9600 @ 20Mhz as Table
RCSTAbits.SPEN=1; // Enable Serial Port
}
void write_usart(void) //Write to the USART
{
while(TXSTAbits.TRMT==1)
TXREG='A';
}
void main (void)
{
TRISC=0x80; //Set RC7=Input, RC0:6 as Output
init_usart(); // Initialise the USART
write_usart();
}
hi, i am currently using PIC16f886, pickit2, MPlab for a project. i editted the codes i obtained from the sample codes taken from the HiTechC folders.
can i know where will the "A" be displayed at? how do we actually do that?
pls help me as this project is really crucial to me and am rather clueless/confused of my next step. solving this current problem of mine is an intermediate step to go to the next step - configuring AT commands for the p16f886 and rs232 and BT module
Firstly dont hijack an other persons thread.It doesnt give you any more replies then you would have gotten in one of your own.If you send an "a" to a computer through a serial port it will be displayed on the top left of the screen.If you want to position it then use carriage return spaces etc.