ep.hobbyiest
Full Member level 4
![Full Member level 4](/styles/images/ranks/flevel1.gif)
Hi,
I am using PIC18F46k22 controller with 4 MHz crystal. Compiler is XC8.
I configured UART but it is not working. Not single character is transmitting.
What i am doing wrong?
I am using PIC18F46k22 controller with 4 MHz crystal. Compiler is XC8.
I configured UART but it is not working. Not single character is transmitting.
Code:
void initUART(void)
{
TRISBbits.TRISB6 = 1;
TRISBbits.TRISB7 = 1;
TXSTA2 = 0x00;
BAUDCON2 = 0x00;
SPBRG2 = 25;
RCSTA2 = 0x90;
}
void UartSendChar(char ch)
{
TXSTA2bits.TXEN = 1;
TXREG2 = ch;
while(PIR3bits.TX2IF==0);
PIR3bits.TX2IF = 0;
}
What i am doing wrong?