I am running a loop-back test for the Uart Channel 4 (HAL driver - no framework), and while I write and read data, my callback for setting Rx flag is not working correctly.
My ISR appears to continually be interrupted (at least that is how I interpret what's going) so I never get to set the flag, and I therefore can never execute the code needed to be executed. Program just hangs when I poll for a change Rx Flag.
In the callback, if I set a breakpoint on test = 0;, I never hit it, though I do hit the breakpoint when it is set to Uart4_status = true;
void user_uart4_callback(uart_callback_args_t * p_args){
unsigned char test;
if(p_args->channel == 4){ // UART4
switch (p_args->event){
case UART_EVENT_RX_COMPLETE:
uart4_status = true;
test = 0;
break;
// case UART_EVENT_RX_CHAR:
// uart4_status = true;
// test = 0;
// break;
}//end switch
}//end if(p_args->channel == 4)
}//end user_uart4_callback()
//Perform a loop-back test
for(;;){
if (!usb_id){
// Write data to external device
err = g_uart4.p_api->write(g_uart4.p_ctrl, msg, sizeof(msg));
if(err != SSP_SUCCESS)
while(1);
while(!uart4_status);
uart4_status= false;
err = g_uart4.p_api->read(g_uart4.p_ctrl,uart4_buf,8);
if(err != SSP_SUCCESS)
while(1);
tx_thread_sleep (10);
}//end if (!usb_id)
}//end for(;;)