This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2340R5: CC2340R5 : UART callback not working properly.

Part Number: CC2340R5

Hello, 

I'm using CC2340R5 SDK, version 7.40, basic_ble project.

I'm reading and writing data on UART_2. I'm sending commands on UART from MCU to BLE at initial but if BLE is disconnected/is in broadcasting mode, the UART callback function does not trigger. 

While reading the callback function, it only triggers when I make a peripheral connection with android application.

In peripheral also, the callback does not always triggers. It sometimes misses the callback. Although, I get the data on UART. 

Below is my code: 

UART configuration: 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void *mainThread(void *arg0)
{
char input;
const char echoPrompt[] = "Echoing characters:\r\n";
UART2_Params uartParams;
int32_t semStatus;
uint32_t status = UART2_STATUS_SUCCESS;
uint8_t tempbuf[64] = {0};
/* Create semaphore */
// semStatus = sem_init(&sem, 0, 0);
// if (semStatus != 0)
// {
// /* Error creating semaphore */
// // while (1) {}
// }
/* Create a UART in CALLBACK read mode */
UART2_Params_init(&uartParams);
uartParams.readMode = UART2_Mode_BLOCKING;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

UART Callback: 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void callbackFxn(UART2_Handle handle, void *buffer, size_t count, void *userArg, int_fast16_t status)
{
// uint8_t tempbuf[260] = {0};
if (status != UART2_STATUS_SUCCESS)
{
/* RX error occured in UART2_read() */
// while (1) {}
}
status = UART2_read(uart_handle, buffer, sizeof(count), NULL);
BLE_MCU_Cmd_parser(buffer);
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Calling in main() function: 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int main()
{
pthread_t thread;
pthread_attr_t attrs;
struct sched_param priParam;
int retc;
/* Register Application callback to trap asserts raised in the Stack */
halAssertCback = AssertHandler;
RegisterAssertCback(AssertHandler);
Board_init();
/* Initialize the attributes structure with default values */
pthread_attr_init(&attrs);
/* Set priority, detach state, and stack size attributes */
priParam.sched_priority = 1;
retc = pthread_attr_setschedparam(&attrs, &priParam);
retc |= pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED);
retc |= pthread_attr_setstacksize(&attrs, THREADSTACKSIZE);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX