Tool/software:
Hello.
I am using the CC2340R5 and the UART module.
When we upgraded from SDK 8.20 to 8.40, we discovered that UART receive interrupts were no longer possible.
Although it was still under analysis, the UART itself was enabled and NONBLOKING transmission was possible.
Reception uses callback with FIFO.
It is implemented exactly like the example in the driver manual.
It seems that when the SDK was changed, a factor was introduced that caused the receive interrupt to not be received, but even after spending several days, the problem has not been resolved.
I would like your support.
Thank you very much.
Hello.
The SDK example is not used.
It was created by accessing docs > drivers > tidriversAPIs.html in the SDK and referring to the UART2.h File Reference Detailed Description.
Thanks.
Hello,
I am working through this, expect me to reply by Monday (03-10) . I appreciate your patience.
Regards,
Tarek
Hello.
Thank you for your confirmation.
I will send you the code snippet.
I omitted explaining this, but one UART module is used to switch between two communication lines.
The communication lines used are as shown in the table below.
Comm \ Port | RX | TX |
UART 0 | DIO 12 | DIO 13 |
UART1 | DIO 16 | DIO 17 |
This is a code snippet that switches UART at any timing/condition.
static void Callback_UART(UART2_Handle Handle, void *Buffer, size_t Count, void *UserArg, int_fast16_t Status); static void Callback_UART1(UART2_Handle Handle, void *Buffer, size_t Count, void *UserArg, int_fast16_t Status); void UART_InitUART( void ); void UART_InitUART1( void ); UART_StopUART( void ); UART_StopUART1( void ); UART2_Handle Handle; UART2_Handle Handle1; static uchar UartState = 0U; static uchar Uart1State = 0U; static uchar UartRDataBuf[UART_DATA_BUF_SIZE]; void switchUART() { UART_StopUART1(); UART_Init(); } void switchUART1() { UART_StopUART(); UART1_Init(); } void StopUART( void ) { if( UartState != 0U ) { UART2_close( Handle ); UartState = 0U; } } void StopUART1( void ) { if( Uart1State != 0U ) { UART2_close( Handle1 ); Uart1State = 0U; } } void UART_Init( void ) { UART2_Params UartParams; int_fast16_t Status; /* Create a UART where the default read and write mode is BLOCKING */ UART2_Params_init(&UartParams); UartParams.readMode = UART2_Mode_CALLBACK; UartParams.writeMode = UART2_Mode_NONBLOCKING; UartParams.readCallback = Callback_UART; UartParams.baudRate = 38400U; // initialize a given UART peripheral if( UartState == 0U ) { Handle = UART2_open(0, &UartParams); UartState = 1U; if (Handle == NULL) { while(1); } UART2_rxEnable(Handle); Status = UART2_read(Handle, &UartRDataBuf, UART_DATA_BUF_SIZE, NULL); // Don't remove for read callback if( Status != UART2_STATUS_SUCCESS ) { while(1); } } } void UART1_Init( void ) { UART2_Params UartParams; int_fast16_t Status; /* Create a UART where the default read and write mode is BLOCKING */ UART2_Params_init(&UartParams); UartParams.readMode = UART2_Mode_CALLBACK; UartParams.writeMode = UART2_Mode_NONBLOCKING; UartParams.readCallback = Callback_UART1; UartParams.baudRate = 9600U; if( Uart1State == 0U ) { Handle1 = UART2_open(1, &UartParams); Uart1State = 1U; if (Handle1 == NULL) { while(1); } UART2_rxEnable(Handle1); Status = UART2_read(Handle1, &UartRDataBuf, UART_DATA_BUF_SIZE, NULL); // Don't remove for read callback if( Status != UART2_STATUS_SUCCESS ) { while(1); } } }
Hello Kei,
Thank you for providing the code! This code seems fine to me. UART is fully functional in the SDK, so I still don't understand what is causing this problem. What is the callback function doing? Could you provide a description of the function or possibly a code snippet?
Best Regards,
Tarek
Hello.
The callback function receives data and checks for errors.
Callback_UART
UART2_read(Handle, &UartRDataBuf, UART_DATA_BUF_SIZE, NULL);
Callback_UART1
UART2_read(Handle1, &UartRDataBuf, UART_DATA_BUF_SIZE, NULL);
Thank you.
Hello Kei,
Thank you for providing the function! Just to clarify, you're saying that the callback function is never being called?
Best Regards,
Tarek
Hello Kei,
I really appreciate your patience! I was unable to recreate the issue, as the UART callback worked fine on my end. Could you please try testing the uart2callback example provided in the SDK, and see if that works for you? The project is located inside the SDK in:
examples -> rtos -> LP_EM_CC2340R5 ->drivers -> uart2callback
Please test this and let me know if it works.
Best Regards,
Tarek
Hello,
I see.
What is the point of revisiting a phenomenon using an example?
I would like to try it, but I don't have enough time to implement it.
Is there another way to address the problem?
For example, were there any changes made in simplelink_lowpower_f3_sdk 8.20 and 8.40 that could cause this problem?
Best Regards,
Hello Kei,
Upon looking further into this, you're right! There were some changes made to the new SDK (8.40). I've attached a project that does UART switching. I believe it will be very helpful to structure your UART calls based on it! Please let me know if you have any more questions.
uart2switching_echo_CC2340R53.zip
Best Regards,
Tarek
Thank you for your help.
I would like to know the source code to change from the SWD pin to UART1.
Also, is the source code to change from the UART1 pin to the SWD pin correct?
If there is a problem, please fix it.
Below is the source code.
#define UART1_RX 16 #define UART1_TX 17 void SetPortUART( void ); void SetPortSWD( void ); // Change from SWD to UART1 void SetPortUART( void ) { GPIO_resetConfig(UART1_RX); GPIO_resetConfig(UART1_TX); (void)GPIO_setConfig(UART1_RX, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_NONE ); (void)GPIO_setConfig(UART1_TX, GPIO_CFG_OUTPUT_INTERNAL | GPIO_CFG_OUT_STR_MED | GPIO_CFG_OUT_HIGH); HWREG(DBGSS_BASE + DBGSS_O_DBGCTL) = 0U; } // Change from UART1 to SWD void SetPortSWD( void ) { GPIO_resetConfig(UART1_RX); GPIO_resetConfig(UART1_TX); HWREG(DBGSS_BASE + DBGSS_O_DBGCTL) |= DBGSS_DBGCTL_SWDCEN_EN; }
Best Regards,
Hello,
As seen in the example attached, gpio configuration should be as follows:
GPIO_setConfigAndMux(newTxPin, GPIO_CFG_OUTPUT_INTERNAL | GPIO_CFG_OUT_STR_MED | GPIO_CFG_OUT_HIGH, newTxMux); GPIO_setConfigAndMux(newRxPin, GPIO_CFG_INPUT_INTERNAL | GPIO_CFG_IN_INT_NONE | GPIO_CFG_PULL_DOWN_INTERNAL, newRxMux);
UART 1 -> DIO13 and DIO12
UART 2 -> DIO20 and DIO22
Upon setting the pins as mentioned,, switching should be working.
Best Regards,
Tarek
Hello Tarek,
I have checked your advice and the source code.
We conducted a reproduction test on a custom board.
Unfortunately, the problem was not solved.
Is there anything else I can look into to try to resolve this?
Upon looking further into this, you're right! There were some changes made to the new SDK (8.40). I've attached a project that does UART switching. I believe it will be very helpful to structure your UART calls based on it! Please let me know if you have any more questions.
Hello Kei,
Thank you for your patience. Is this behavior seen on a launchpad? If you haven't tested, could you please test the example I attached earlier and let me know?
Best regards,
Tarek
Hello Tarek,
Thank you for your consideration.
I made the changes in the thread below and the problem was resolved.
There was a change that was missed when sysconfig was upgraded from 1.20 to 1.22.
thank you.