LPUART_RTOS_Send() stop FreeRTOS SwTimer period

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPUART_RTOS_Send() stop FreeRTOS SwTimer period

Jump to solution
1,564 Views
felix1
Contributor IV

Hi, 

I want to send UART message every 1 second, so I combine examples 

evkbimxrt1050_freertos_lpuart and evkbimxrt1050_freertos_swtimer to test.

But add LPUART_RTOS_Send() to SwTimerCallback() stop the SwTimer 1 second period callback, comment LPUART_RTOS_Send() the SwTimer period is normal.

I attached the modified freertos_lpuart.c. 

How to fix it and send UART message 1 second period?

p.s. RT1050 SDK 2.10.0

 

Labels (1)
Tags (1)
0 Kudos
1 Solution
1,403 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @felix1,

Yes, replacing fsl_lpuart_freertos.c /.h and fsl_lpuart.c /.h should make the timer and uart work.

Just a heads up, you should replace the whole code in "freertos_swtimer.c" as it may be incompatible in some other parts of the code, other than that, everything should be ok.

Don't hesitate to ask if anything else comes up!

Best regards, Julian

View solution in original post

0 Kudos
8 Replies
1,494 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @felix1,

I apologize for the late response. I was able to reproduce the 1 second period callback for the Send() function in UART. I found it easier to start with the timer example, and then add in the LPUART peripherals and drivers.

Please, create a new freertos_swtimer, open Config Tools from the project explorer, and add in the uart drivers. (You will also need to manually add the "fsl_lpuart_freertos" inside the "freertos" folder on the LPUART example.

After this, copy all the initialization and variables needed for the send function (Definitions, Prototypes and Code).

Add "NVIC_SetPriority(LPUART1_IRQn, 5);", and add the UART task to the scheduler for the initialization.

I was able to reproduce it by removing all but the initialization in the "uart_task" function, and just adding "LPUART_RTOS_Send(&handle, (uint8_t *)to_send, strlen(to_send));" inside the SwTimerCallback function to avoid the Receive function inside the example.

I apologize again for the tardy response, but I hope you find this helpful!

0 Kudos
1,483 Views
felix1
Contributor IV

Hi @Julián_AragónM ,

I followed your procedure based on the new project evkbimxrt1050_freertos_swtimer to add UART send function, but it still failed to send UART message in SwTimerCallback() 1 second period.

Can you export and attach your project for reference?

0 Kudos
1,478 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @felix1,

Could you please help me check all the includes, prototypes and definitions are in place? If so, please check for the priority line, and the UART TaskCreate function, the "Send" function inside the timer callback, and to comment the "Send" and all of the receiving part of the UART's task.

 

  1. Julin_AragnM_0-1666106601210.png

     

 

  1. Julin_AragnM_1-1666106601211.png

     

 

  1. Julin_AragnM_2-1666106601211.png

     

 

If it still doesn't work, please try adding a minimal delay after the UART initialization and try to communicate again.

Julin_AragnM_4-1666106338029.png

This is the constant output on terminal. "Tick." refers to the PRINTF inside the callback function, and the FreeRTOS LPUART line refers to the "LPUART_RTOS_Send" function.

I hope you find this helpful!

Best regards, Julian

0 Kudos
1,468 Views
felix1
Contributor IV

Hi @Julián_AragónM 

Since you use API LPUART_RTOS_SetRxTimeout() (althougt you comment it), I guess your are using SDK 2.12.0.

Following your instructions to modify evkbimxrt1050_freertos_swtimer project, my tests are SDK 2.12.0 is ok to send UART message one second period, but SDK 2.10.0 is failed.

I guess if you test your project in SDK 2.10.0, you may get the fail result.

 

I attach my file generated from SDK 2.10.0 for reference, the test result is failed.

0 Kudos
1,449 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @felix1,

Yes, we always recommend using the latest SDK and IDE version. Is there a specific reason you might choose SDK 2.10 over the newest version?

Best regards, Julian

0 Kudos
1,428 Views
felix1
Contributor IV

Hi @Julián_AragónM ,

I have developed the project and released to customer based on SDK 2.10.0.

Can I just replace 

fsl_lpuart_freertos.c / .h
fsl_lpuart.c / .h

from SDK 2.10.0 to SDK 2.12.0 to fix this UART problem?

0 Kudos
1,404 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @felix1,

Yes, replacing fsl_lpuart_freertos.c /.h and fsl_lpuart.c /.h should make the timer and uart work.

Just a heads up, you should replace the whole code in "freertos_swtimer.c" as it may be incompatible in some other parts of the code, other than that, everything should be ok.

Don't hesitate to ask if anything else comes up!

Best regards, Julian

0 Kudos
1,370 Views
felix1
Contributor IV

Hi @Julián_AragónM ,

 

replace UART driver from SDK 2.10.0 to SDK 2.12.0, and change 

 

lpuart_rtos_config_t lpuart_config = {
.baudrate = 115200,
.parity = kLPUART_ParityDisabled,
.stopbits = kLPUART_OneStopBit,
.buffer = background_buffer,
.buffer_size = sizeof(background_buffer),
};

 

to

 

lpuart_rtos_config_t lpuart_config = {
.baudrate = 115200,
.parity = kLPUART_ParityDisabled,
.stopbits = kLPUART_OneStopBit,
.buffer = background_buffer,
.buffer_size = sizeof(background_buffer),
.rx_timeout_constant_ms = 1,
.rx_timeout_multiplier_ms = 1,
.tx_timeout_constant_ms = 20,
.tx_timeout_multiplier_ms = 1,
};

in freertos_swtimer.c.

It works now.

0 Kudos