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.
Tool/software: TI-RTOS
Support Path: /Tools & software/Help me with an issue/Embedded Product Software Tools/RTOS/
Hi all,
I’m trying to get two uart ports operating in TI-RTOS with the MSP432 1.40.00.28 SDK.
One of them is used by Display_printf(), and the other is to an external UART which I have connected to the TX and RX of a FTDI USB to serial which I transmit and receive commands using a serial terminal in my PC. I was able to output on both ports.
Next I needed to do a UART_read. When characters are received I am doing a Semaphore_post in the Uart read callback function.
void UART_Read_CallBack(UART_Handle handle, void *buffer, size_t num) { Semaphore_post(uart3gSemHandle); }
The Semaphore_pend is then done in the Uart parsing function, where if the Semaphore_pend was successful, it will know that there’s UART data to receive and therefore do the UART_read. Upon reading it, I get it to echo it back on to my terminal through a write, so that I know it was read.
void *Uart3gParserTask(void *arg0) { const char testString[] = "Testing\r\n"; Int16 uart3gReturn = 0; /*Create UART instance*/ UART_Params_init(&uart3gParams); uart3gParams.writeMode = UART_MODE_CALLBACK; uart3gParams.readMode = UART_MODE_CALLBACK; uart3gParams.writeDataMode = UART_DATA_BINARY; uart3gParams.readDataMode = UART_DATA_BINARY; uart3gParams.readCallback = UART_Read_CallBack; uart3gParams.writeCallback = UART_Write_Callback; uart3gParams.readReturnMode = UART_RETURN_FULL; uart3gParams.readEcho = UART_ECHO_OFF; uart3gParams.baudRate = 115200; uart3g = UART_open(Board_UART1, &uart3gParams); // UART1 is eusciA2 Semaphore_Params_init(&uart3gSemParams); uart3gSemParams.mode = ti_sysbios_knl_Semaphore_Mode_BINARY; uart3gSemParams.instance->name = "OurSem3g"; Semaphore_construct(&uart3gSemStruct, 1, &uart3gSemParams); uart3gSemHandle = Semaphore_handle(&uart3gSemStruct); if(uart3g == NULL) { Display_printf(myDisplay, 0, 0, "Error - UART did not open\r\n"); } UART_write(uart3g, testString, sizeof(testString)); // Only for testing while(1) { //pend a semaphore here. This will block the while loop and let other tasks run, until semaphore is posted in UART read callback Int semCount = Semaphore_getCount(uart3gSemHandle); Semaphore_pend(uart3gSemHandle, BIOS_WAIT_FOREVER); semCount = Semaphore_getCount(uart3gSemHandle); uart3gReturn = UART_read(uart3g, &uart3gRxChar, 7 ); GPIO_toggle(Board_GPIO_LED1); UART_write(uart3g, &uart3gRxChar, sizeof(uart3gRxChar)); usleep(10); } }
1) In the while(1) loop, the Semaphore_getCount returns 1 before Semaphore_pend. After going past Semaphore pend it is 0. Which is what’s meant to happen. However, next time it comes around the while loop, it gets past Semaphore_pend even if the Semaphore_getCount is 0. This is very confusing, because the semaphore is meant to not go beyond this point till the semaphore is posted. In this case, from the Uart read callback function. Even more confusing is how the semaphore was 1 first time around, without even the UART_Read_CallBack function firing even once since start of the program, UART_Read_CallBack is the only place Semaphore_post is done. I observed this phenomenon using breakpoints to check semCount before and after the Semaphore_Pend .
2) The other problem I came across is that, if I remove breakpoints, it will print a couple of characters to my terminal and jump in to a Hwi exception handler. In here it gets stuck in the continuous loop. Certainly I haven't got a handler for this exception, but why this happened, I coulcn't understand.
Void Hwi_excHandler(UInt *excStack, UInt lr) { Hwi_module->excActive[0] = TRUE; /* spin here if no exception handler is plugged */ while (Hwi_excHandlerFunc == NULL) { ; } Hwi_excHandlerFunc(excStack, lr); }![]()
I thought I should attach a screenshot of the ROV which was captured once it got stuck in the continuous loop in the Hwi exception handler, as it may be useful. I am very new to TI-RTOS, therefore still in the early stages. Is anyone able to help me with the two issues please? Please let me know if there's any other information that I could provide. Thank you in advance.
Kind regards,
Guyan
Hello,
A ROV snapshot will be very useful.
Also, some time ago I put together this example code.
1. It was based on the uartecho
2. Display out on EUSCI_A0
3. Configure EUSCI_A3 as UART with callback
4. Added your semaphore definition and it is being used in the uart write callback.
I'm hoping this could help us track down your Hwi exception.
Best regards,
David
**Attention** This is a public forum