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.
Part Number: MSP432P401R
Hello There,
I have set up UART with following settings
writeDataMode = UART_DATA_TEXT;
readDataMode = UART_DATA_TEXT;
readReturnMode = UART_RETURN_NEWLINE;
readEcho = UART_ECHO_OFF;
baudRate = 115200;
readTimeout = 200;
writeTimeout = 400;
I'm facing issue when I'm trying to read some uart data from GPIO Button ISR.
When there is no data available to be read and whenever UART_read(uartA2Handle, input, sizeof(input)) from Button ISR tries to read, it's returning the size of input buffer and every index of buffer is holding the '0X0E'. Rather it should return zero.
It's working perfectly when called from a TASK .
See the below code for details.
* ======== gpioButtonFxn0 ======== * Callback function for the GPIO interrupt on Board_GPIO_BUTTON0. */ void gpioButtonFxn0(uint_least8_t index) { char input[100]; int rxlen = 0; memset(input, 0, sizeof(input)); /* Clear the GPIO interrupt and toggle an LED */ GPIO_toggle(Board_GPIO_LED0); rxlen = UART_read(uartA2Handle, input, sizeof(input)); //here rxlen comes to 100 still when there is no data available to read. while(1); } /* * ======== mainThread ======== */ void *mainThread(void *arg0) { /* Call driver init functions */ GPIO_init(); UART_init(); uartA2Params.writeDataMode = UART_DATA_TEXT; uartA2Params.readDataMode = UART_DATA_TEXT; uartA2Params.readReturnMode = UART_RETURN_NEWLINE; uartA2Params.readEcho = UART_ECHO_OFF; uartA2Params.baudRate = 115200; uartA2Params.readTimeout = 200; uartA2Params.writeTimeout = 400; uartA2Handle = UART_open(Board_UART1, &uartA2Params); if (uartA2Handle == NULL) { /* UART_open() failed */ while(1); } /* Configure the LED and button pins */ GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW); GPIO_setConfig(Board_GPIO_LED1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW); GPIO_setConfig(Board_GPIO_BUTTON0, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING); /* Turn on user LED */ GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON); /* install Button callback */ GPIO_setCallback(Board_GPIO_BUTTON0, gpioButtonFxn0); /* Enable interrupts */ GPIO_enableInt(Board_GPIO_BUTTON0); sleep(2); char input[100]; int rxlen = 0; memset(input, 0, sizeof(input)); /* Clear the GPIO interrupt and toggle an LED */ GPIO_toggle(Board_GPIO_LED0); rxlen = UART_read(uartA2Handle, input, sizeof(input)); //here rxlen comes to zero after UART_read() when there is no data to read. while(1); return (NULL); }
Regards,
Keshav Aggarwal
Hi,
We will look into it and get back to you ASAP. Please bear with us.
Thanks,
PM
Hello FI,
I have added while(1) in the callback for debugging purposes So, that I can set a break point and view the contents of buffer.
Regards,
Keshav Aggarwal
Hi Keshav,
I tried to replicate your issue but i did not see the same. My buffer returns all zeros.
Regards,
Hello FI,
I have just found GPIO peripheral and UART have same Interrupt priorities. That definitely might be causing this issue.
I'll give UART a higher priority than GPIO Input pin and will update soon.
BR,
Keshav Aggarwal
**Attention** This is a public forum