Hi, I am trying to run event based UART. here is my code snippet:
void uart_callback(app_uart_evt_t *p_app_uart_event)
{
uint8_t rxbyte;
switch(p_app_uart_event->evt_type)
{
case APP_UART_DATA_READY:
while((app_uart_get(&rxbyte) == NRF_SUCCESS))
{
rx_buffer[rx_buf_len++] = rxbyte;
if(rxbyte == '\n')
{
uart_putstring(rx_buffer);
rx_buf_len = 0;
break;
}
if(rx_buf_len == RX_BUFF_SIZE)
break;
}
/********************************************/
/* if(app_uart_get(&rxbyte) == NRF_SUCCESS) */
/* app_uart_put(rxbyte); */
/********************************************/
break;
case APP_UART_TX_EMPTY:
break;
case APP_UART_COMMUNICATION_ERROR:
break;
case APP_UART_FIFO_ERROR:
break;
default:
break;
}
}
/**@brief Function for initializing the UART module.**/
static void uart_init(void)
{
static const app_uart_comm_params_t comm_params =
{
.rx_pin_no = RX_PIN_NUMBER,
.tx_pin_no = TX_PIN_NUMBER,
.rts_pin_no = RTS_PIN_NUMBER,
.cts_pin_no = CTS_PIN_NUMBER,
.flow_control = APP_UART_FLOW_CONTROL_DISABLED,
.use_parity = false,
.baud_rate = UART_BAUDRATE_BAUDRATE_Baud4800
};
uint32_t errcode = 0;
rx_buf_len = 0;
APP_UART_FIFO_INIT(&comm_params, RX_BUFF_SIZE, TX_BUFF_SIZE, uart_callback, APP_IRQ_PRIORITY_LOW, errcode);
//APP_UART_INIT(&comm_params, uart_callback, APP_IRQ_PRIORITY_LOW, errcode);
APP_ERROR_CHECK(errcode);
}
in main() among others I am calling uart_init() which initialises uart and enables interrupts as you can see above in code. when uart interrupt occurs my uart_callback should be called, but when I connect 6310 motherboard's rs232 to PC nothing happens. Could you please help me? what I am doing wrong? I am using:
gcc Compiler
6310 Motherboard + pca1004
SDK Version 6.1.0.0
Kind Regards Shuhrat