im trying to send the character 'A' from the PIC 16F877A to the Hyper Terminal of a PC asynchronously.
Ive read the 877a datasheet concerning the setting up of transmit and receive registers, baud rates, and TXIE, TXIF, RXIE, RXIF flags..
I also understand how characters are communicated in ASCII between PC and PIC.
I also understand the need of voltage level converters between the PC and PIC and for this im using the Max 232 which i have successfully constructed and tested..
i am now currently developing my code in c and have came up with the following so far:
Excerpting from my above code,
void putch(unsigned char a)
{
TXREG=a;
}
I would like to know whether this implementation is the correct way of sending out a string through the Tx Pin. Supposingly I have a long string, should I send out the data byte by byte?
(I am actually trying to send AT commands to a handphone via a serial data cable and as i have no experience implementing serial comm in a pic, im trying to send characters to the hyper terminal first.)
Any opinions on how i should learn to develop my code/online resources are also appreciated=)
Ive read the 877a datasheet concerning the setting up of transmit and receive registers, baud rates, and TXIE, TXIF, RXIE, RXIF flags..
I also understand how characters are communicated in ASCII between PC and PIC.
I also understand the need of voltage level converters between the PC and PIC and for this im using the Max 232 which i have successfully constructed and tested..
i am now currently developing my code in c and have came up with the following so far:
void serial_setup(void)
{
SPBRG=25; //im using 9600baud
BRGH=1; //data rate for sending
SYNC=0; //asynchronous
SPEN=1; //enable serial port pins
CREN=1; //enable reception
SREN=0; //no effect
TXIE=0; //disable tx interrupts
RCIE=0; //disable rx interrupts
TX9=0; //8-bit transmission
RX9=0; //8-bit reception
TXEN=0; //reset transmitter
TXEN=1; //enable the transmitter
}
void putch(unsigned char a)
{
TXREG=a;
}
void main()
{
TRISB=0xFF;
serial_setup();
if(RB0)
{
putch('A');
}
}
Excerpting from my above code,
void putch(unsigned char a)
{
TXREG=a;
}
I would like to know whether this implementation is the correct way of sending out a string through the Tx Pin. Supposingly I have a long string, should I send out the data byte by byte?
(I am actually trying to send AT commands to a handphone via a serial data cable and as i have no experience implementing serial comm in a pic, im trying to send characters to the hyper terminal first.)
Any opinions on how i should learn to develop my code/online resources are also appreciated=)