bing2005
Junior Member level 2
hi-tech usart
I am using the PIC16f877 to write the source code above.
But, i cannot get the desire output.
Please help me guys.
Thanks a lot.[/code]
Code:
#include <pic.h>
#include <stdio.h>
void config(void);
void srl(void);
void start(void);
void main(void)
{
config();
srl();
while(1)
{
start();
}
}
void config(void)
{
STATUS |= 0x20;
TRISC7 = 1;
TRISC6 = 0;
STATUS &= 0xdf;
}
void srl(void)
{
BRGH = 1; /* high baud rate */
SPBRG = 25; /* set the baud rate */
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- or 9-bit transmission */
RX9 = 0; /* 8- or 9-bit reception */
TXEN = 1; /* enable the transmitter */
}
void start(void)
{
printf("The distance is 5cm.");
}
But, i cannot get the desire output.
Please help me guys.
Thanks a lot.[/code]