PEx uart example

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

PEx uart example

跳至解决方案
2,106 次查看
peterkostadinov
Contributor III

Hello All,

I can't find example of using UART TxCallBack. I'm using kl43 dev board, KDS 3.0 and KSDK 1.3.

Inside KDS 3.0 there are examples of uart using, but they are not with callback.

Thank You in advance.

Best Regards,

Peter

标签 (1)
0 项奖励
回复
1 解答
1,498 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello peter,

I have check the project i send to you, yes ,it have error .

It perform the callback function , while the error is that it shouldn't use the function of UART in the callback function .

For it locked in the callback function.

And so , refer to your requirement , i recommend you use the polling mode , do not  use the callback .

Hope it helps

Alice

在原帖中查看解决方案

0 项奖励
回复
4 回复数
1,498 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Peter,

I refer to my colleagues Xiangjun Rong’s demo code  (you can find here : https://community.freescale.com/message/538622#538622)

crete one demo about kl43-UART calllback for you .  My demo code is about KDS3.0-KSDK1.3 .

It based on the example the SDK1.3 provides:

\Freescale\KSDK_1.3.0\examples\frdmkl43z\driver_examples\lpuart\lpuart_non_blocking\kds .

You only need changed the main.c of the project to my attachment "main.c"  .

I have test , the callback function works well.

The main changed code is :

pFunc = (lpuart_tx_callback_t *)uart_Callback;
LPUART_DRV_InstallTxCallback(BOARD_DEBUG_UART_INSTANCE,(lpuart_tx_callback_t)pFunc,0,NULL);

txChar='B';

LPUART_DRV_SendData(BOARD_DEBUG_UART_INSTANCE, &txChar, 1u); 

Hope it helps

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

Have a great day,
Alice

0 项奖励
回复
1,498 次查看
peterkostadinov
Contributor III

Hello Alice,

Thanks for your quick response.

In the example that You gave me, callback function does not perform any task. Sorry, but I probably did not formulate my question very well and that You do not give me the answer I expected. I will explain in detail my goal.

The data that must be sent by serial interface is of undefined length and arrive at an unspecified time. My goal is to store the data into a structure of type FIFO (eg queue) and allow interrupts on  TX_ready. When callback function is called, it checks for the presence of data in the queue and transmit next byte. If queue is empty - callback function disables interrupts. Something similar is implemented in the KDS legacy uart driver, but instead uses of queue is used rotating list.

In my case, the problem is how to make the process to start sending the very first byte. If I insert the byte in the queue, it is still not allowed interrupt. If I allow interruptions by hand, the interruption will be called, but interrupt function will exit immediately because "isTxBusy" is not set. If "isTxBusy" is set by me, then will be transmitted byte which is in "txBuff", but who will put my byte inside this "txBuff"?

Perhaps the solution is very simple but I did not find it.

Furthermore, project you have indicated did not use PEx, although this is the smallest problem.

Best Regards,

Peter

0 项奖励
回复
1,499 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello peter,

I have check the project i send to you, yes ,it have error .

It perform the callback function , while the error is that it shouldn't use the function of UART in the callback function .

For it locked in the callback function.

And so , refer to your requirement , i recommend you use the polling mode , do not  use the callback .

Hope it helps

Alice

0 项奖励
回复
1,498 次查看
peterkostadinov
Contributor III

Hello Alice,

Thank You for the information.

Polling mode is not suitable in my case, so I'll switch to older (and more expensive) mcu kl46, which is supported by "legacy" driver.

Because of this error now I own redundant development board with mcu kl43, wasted two weeks work, and only luck that kl46 is pin-pin compatible with kl43 save me from routing new board to our device.

I hope this error will be corrected in the next version of drivers.

Best Regards,

Peter

0 项奖励
回复