I'm trying to develop a program for reading from UART port by interruptions using the library provided with eclipse in:
Code: Select all
#include "mcu/microchip_dspic/inc/ee_uart.h"
Code: Select all
EE_uart_init(EE_UART_PORT_1, 57600, EE_UART_BIT_STOP_1 | EE_UART_BIT8_NO, EE_UART_CTRL_SIMPLE);
EE_uart_set_rx_callback(EE_UART_PORT_1, &UART_Rx_cbk, EE_UART_RX_INT_SINGLE);
Code: Select all
void UART_Rx_cbk(EE_UINT8 data)
{
if (data == 0x01)
{
// led on
LATBbits.LATB14 = 1;
}
else
{
// led off
LATBbits.LATB14 = 0;
}
}
Code: Select all
void UART_Rx_cbk(EE_UINT8 data)
unsigned short valor;
if (U1STAbits.OERR)
{ // Receiver buffer has overflowed
U1STAbits.OERR = 0;
return;
}
if (U1STAbits.URXDA)
{ // Receiver buffer has data. At least one more character can be read
valor = U1RXREG & 0x00FF;
if (valor == 1)
{
// LEDs ON
}
else
{
// LEDs OFF
}
}
// reset RX interrupt flag
IFS0bits.U1RXIF = 0;
}