Why I change the lpuart priority cause lpuart send failed?S32K148

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

Why I change the lpuart priority cause lpuart send failed?S32K148

Jump to solution
1,714 Views
Licunhao
Contributor II
Please help to review the follow code;
 
When I open the comment for change the uart priority to 2, uart can not send data.
 
void uart_init(void) {
uint8_t uart_proi = 0;
UART_Init(&uart_pal1_instance, &uart_pal1_Config0);
 
INT_SYS_DisableIRQ(LPUART1_RxTx_IRQn);
uart_proi = INT_SYS_GetPriority(LPUART1_RxTx_IRQn);
// INT_SYS_SetPriority(LPUART1_RxTx_IRQn, 2);
uart_proi = INT_SYS_GetPriority(LPUART1_RxTx_IRQn);
INT_SYS_EnableIRQ(LPUART1_RxTx_IRQn);
 
GE_LOGI(LOG_TAG "uart_proi = %d", __func__, uart_proi);
// start uart rx
UART_ReceiveData(&uart_pal1_instance, uart_rx_buf, 1);
}
 
void uart_send_data(uint8_t *data, uint32_t size) {
uint32_t bytesRemaining;
UART_SendData(&uart_pal1_instance, data, size);
// blocking here if change priority
while (UART_GetTransmitStatus(&uart_pal1_instance, &bytesRemaining) != STATUS_SUCCESS)  {
 
}
}
 
 
Labels (1)
0 Kudos
Reply
1 Solution
1,637 Views
Licunhao
Contributor II

I solved this problem.

Just must change priority after vTaskStartScheduler.

I think it root case is osif_freertos.c should work after TaskStartScheduler.,

 

Close

View solution in original post

0 Kudos
Reply
4 Replies
1,638 Views
Licunhao
Contributor II

I solved this problem.

Just must change priority after vTaskStartScheduler.

I think it root case is osif_freertos.c should work after TaskStartScheduler.,

 

Close

0 Kudos
Reply
1,692 Views
danielmartynek
NXP TechSupport
NXP TechSupport
0 Kudos
Reply
1,707 Views
Licunhao
Contributor II

And I also use FreeRTOS.

0 Kudos
Reply
1,702 Views
Licunhao
Contributor II
without FreeRTOS.IT works well.
with FreeRTOS.IT works fail. Why?
0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2004270%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EWhy%20I%20change%20the%20lpuart%20priority%20cause%20lpuart%20send%20failed%3FS32K148%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2004270%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CDIV%3EPlease%20help%20to%20review%20the%20follow%20code%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EWhen%20I%20open%20the%20comment%20for%20change%20the%20uart%20priority%20to%202%2C%20uart%20can%20not%20send%20data.%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3Evoid%20uart_init(void)%20%7B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Euint8_t%20uart_proi%20%3D%200%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EUART_Init(%26amp%3Buart_pal1_instance%2C%20%26amp%3Buart_pal1_Config0)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EINT_SYS_DisableIRQ(LPUART1_RxTx_IRQn)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Euart_proi%20%3D%20INT_SYS_GetPriority(LPUART1_RxTx_IRQn)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%2F%2F%20INT_SYS_SetPriority(LPUART1_RxTx_IRQn%2C%202)%3B%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Euart_proi%20%3D%20INT_SYS_GetPriority(LPUART1_RxTx_IRQn)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EINT_SYS_EnableIRQ(LPUART1_RxTx_IRQn)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EGE_LOGI(LOG_TAG%20%22uart_proi%20%3D%20%25d%22%2C%20__func__%2C%20uart_proi)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%2F%2F%20start%20uart%20rx%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EUART_ReceiveData(%26amp%3Buart_pal1_instance%2C%20uart_rx_buf%2C%201)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%7D%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3Evoid%20uart_send_data(uint8_t%20*data%2C%20uint32_t%20size)%20%7B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Euint32_t%20bytesRemaining%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EUART_SendData(%26amp%3Buart_pal1_instance%2C%20data%2C%20size)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%2F%2F%20blocking%20here%20if%20change%20priority%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3Ewhile%20(UART_GetTransmitStatus(%26amp%3Buart_pal1_instance%2C%20%26amp%3BbytesRemaining)%20!%3D%20STATUS_SUCCESS)%26nbsp%3B%20%7B%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%7D%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2004270%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3ES32%20SDK%20for%20S32K1%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2004674%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Why%20I%20change%20the%20lpuart%20priority%20cause%20lpuart%20send%20failed%3FS32K148%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2004674%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20solved%20this%20problem.%3C%2FP%3E%3CP%3EJust%20must%20change%20priority%20after%26nbsp%3BvTaskStartScheduler.%3C%2FP%3E%3CP%3EI%20think%20it%20root%20case%20is%20osif_freertos.c%20should%20work%20after%20TaskStartScheduler.%2C%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EClose%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2004323%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Why%20I%20change%20the%20lpuart%20priority%20cause%20lpuart%20send%20failed%3FS32K148%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2004323%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F244004%22%20target%3D%22_blank%22%3E%40Licunhao%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EI%20think%20it%20is%20well%20explained%20here%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.freertos.org%2FDocumentation%2F02-Kernel%2F03-Supported-devices%2F04-Demos%2FARM-Cortex%2FRTOS-Cortex-M3-M4%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.freertos.org%2FDocumentation%2F02-Kernel%2F03-Supported-devices%2F04-Demos%2FARM-Cortex%2FRTOS-Cortex-M3-M4%3C%2FA%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3EDaniel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2004278%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Why%20I%20change%20the%20lpuart%20priority%20cause%20lpuart%20send%20failed%3FS32K148%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2004278%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Ewithout%20FreeRTOS.IT%20works%20well.%3CBR%20%2F%3Ewith%20FreeRTOS.IT%20works%20fail.%20Why%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2004273%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Why%20I%20change%20the%20lpuart%20priority%20cause%20lpuart%20send%20failed%3FS32K148%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2004273%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EAnd%20I%20also%20use%20FreeRTOS.%3C%2FP%3E%3C%2FLINGO-BODY%3E