IO_IOCTL_SERIAL_WAIT_FOR_TC behaves strange (MQX4.0)

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

IO_IOCTL_SERIAL_WAIT_FOR_TC behaves strange (MQX4.0)

ソリューションへジャンプ
1,724件の閲覧回数
mikhailburakov
Contributor III

Hello!

I am trying to implement support for custom protocol working via RS-485. However I stumbled upon a problem with IO_IOCTL_SERIAL_WAIT_FOR_TC. In my configuration I need to switch a gpio pin after all the data has been sent. To ensure all the data is sent, I tried to use the above ioctl. But on the receiving side I do not get the tail of my data, so it looks like the ioctl returns before all the data is sent. However, I figured out that actually this ioctl does nothing other than waiting for the TC bit in UARTx_S1 register in an infinite loop. I simply removed the ioctl call and replaced it with exact the same infinite loop. Everything started to work as expected afterwards. So my question is, how is this possible? I looked through the serial ioctls part of MQX code and did not found any suspicious calls. For the reference, I am running MQX 4.0.1 on MK20DX256VLK7 CPU. Is there anything I missed in the documentation?

Best regards,

Mikhail Burakov

タグ(3)
1 解決策
1,393件の閲覧回数
mikhailburakov
Contributor III

I am following a good tradition and replying to myself.

Actually it appears there's a bug in MQX source code. The file Freescale_MQX_4_0\mqx\source\io\serial\polled\serl_pol_kuart.c, line 958:

         while( ! sci_ptr->S1 & UART_S1_TC_MASK )
must be replaced with:

         while( ! (sci_ptr->S1 & UART_S1_TC_MASK))

to bring it in peace with operators precedence.

Best regards,

Mikhail Burakov

元の投稿で解決策を見る

3 返答(返信)
1,393件の閲覧回数
davidtietz
Contributor III

Hi Mikhail,

Just wanted to say thank you for your post and findings. It saved me a lot of headache today because I was having a similar problem until I stumbled on your post.

Thanks,

David

0 件の賞賛
返信
1,394件の閲覧回数
mikhailburakov
Contributor III

I am following a good tradition and replying to myself.

Actually it appears there's a bug in MQX source code. The file Freescale_MQX_4_0\mqx\source\io\serial\polled\serl_pol_kuart.c, line 958:

         while( ! sci_ptr->S1 & UART_S1_TC_MASK )
must be replaced with:

         while( ! (sci_ptr->S1 & UART_S1_TC_MASK))

to bring it in peace with operators precedence.

Best regards,

Mikhail Burakov

1,393件の閲覧回数
Martin_
NXP Employee
NXP Employee

Hi Mikhail, you are absolutely right! It will be fixed in next MQX release. Thanks !

0 件の賞賛
返信