#include <p18f452.h>
#include <usart.h>
#pragma romdata CONFIG
_CONFIG_DECL(_CONFIG1H_DEFAULT & _OSC_HS_1H,
_CONFIG2L_DEFAULT & _BOR_ON_2L & _BORV_42_2L,
_CONFIG2H_DEFAULT & _WDT_OFF_2H,
_CONFIG3H_DEFAULT,
_CONFIG4L_DEFAULT & _LVP_OFF_4L,
_CONFIG5L_DEFAULT,
_CONFIG5H_DEFAULT,
_CONFIG6L_DEFAULT,
_CONFIG6H_DEFAULT,
_CONFIG7L_DEFAULT,
_CONFIG7H_DEFAULT);
#pragma romdata
void main(void)
{
unsigned char c;
/* Configure all PORTB pins for output */
TRISB = 0;
OpenUSART (USART_TX_INT_OFF &
USART_RX_INT_ON &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH, 129);
/* Display a prompt to the USART */
putrsUSART ("\n\rEnter 0 or 1!\n\r") ;
while(1)
{
while(!DataRdyUSART())
;
/* Get the character received from the USART */
c = ReadUSART();
if (c == '0')
{
PORTB = 0;
}
else if (c == '1')
{
PORTB = 1 ;
}
}
CloseUSART() ;
}
is there any problem with my code here? Fosc is 20MHz, 9600 Baud rate, 8 bits, no parity, 1 stop bit.