Using UART with RS485 on K64F microcontroller

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

Using UART with RS485 on K64F microcontroller

Jump to solution
2,193 Views
michaelkoller
Contributor III

Hello!

I have to communicate with a motor driver that has a RS485 type physical interface and a given command format. I am now trying to communicate with it via UART on the K64F but the manual (the one with over 1500 pages) has very little information about it. Are there any sources I can look up?

Anything helps, thanks in advance and

best regards,

Michael

0 Kudos
1 Solution
1,542 Views
ndavies
Contributor V

There is no magical software to turn the UART TX and RX pins output into RS485. RS485 is an electrical specification. You will have to add electrical components to the UART TX/RX circuit to convert it to RS485. The UART can talk on a RS485 circuit if the proper electrical components are added.

Your UART code will then need to be modified to deal with RS485 transmitted data looping back in the RX/TX circuit.

View solution in original post

0 Kudos
6 Replies
1,542 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Michael Koller

Yes, I’m sorry if my response cause confusion. Unfortunately we don’t have an example code of RS485 in bareboard, there is only an example code using RTOS, and for this, it is necessary install MQX, and then you can look at the path that I mentioned.

This example code is design to be used with the TWR of NXP, in this case, the twr64f120m, and it’s necessary used the twr-ser1 or twr-ser2.

It is possible that you let us know the version of MQX that you’re installing?

Attached is the "readme" file for the RS485 example

Hope this helps

Jorge Alcala

0 Kudos
1,542 Views
michaelkoller
Contributor III

Also, I don't use Processor Expert or anything like it. I need solutions, that I can implement vie C++ code myself. Thanks

Edit: I should mention that I use Ubuntu. So in order to install it I followed the Getting Started PDF MQX™ Classic Software Solutions|NXP  There it says to look up the

Getting Started with Kinetis Design Studio IDE and Freescale MQXTM RTOS.pdf in the unpacked Download for MQX, which I did.

There it tells me to follow the steps where I need to go to Help-> Install New Software --> got to Freescale Update Site --> check MQX Installations --> proceed with installation.

I find do that and it gives me this error:

An error occurred while collecting items to be installed

session context was:(profile=DefaultProfile, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).

No repository found containing: osgi.bundle,com.freescale.dom4j.lib,1.1.1.201508111009

No repository found containing: osgi.bundle,com.freescale.mqx.gdb.tad,1.0.9.201508111009

No repository found containing: org.eclipse.update.feature,com.freescale.mqx.gdb.tad.eclipse,1.0.9.201508111009

No repository found containing: osgi.bundle,com.freescale.mqx.projectofprojects,1.1.8.201508111009

No repository found containing: org.eclipse.update.feature,com.freescale.mqx.projectofprojects.eclipse,1.1.8.201508111009

What is the problem?

I appreciate any guidance,

Michael

Edit: Another question: Am I correct to assume that with this MQX I won't need additional hardware for rs485? I would like not to have to use a transceiver.

0 Kudos
1,542 Views
michaelkoller
Contributor III

Hello!

Thank you for the answer, but I don't really understand how I should use this information, probably because I'm too inexperienced.

I am using the K64F and not something from the K20 product line.

Do you mean that I can include the right header from the K20 MQX RTOS files in my current K64F project and the correct code from the example project in my main.c?

Optimally, I would like to have some code, that transforms my tx and rx pins (c16 and c17are broken out on the K64F devboard, so I use that) into the rs485+ and rs485- differential signal pins. These pins I could then connect to the the rs485 interface from the driver, which I want to communicate with.

Is this achieveable with the link you sent me (and what's the best way to set it up, then)?

Thanks a lot for the pointer in the hopefully right direction, maybe you can elaborate a little bit more!

Best regards,

Michael

0 Kudos
1,543 Views
ndavies
Contributor V

There is no magical software to turn the UART TX and RX pins output into RS485. RS485 is an electrical specification. You will have to add electrical components to the UART TX/RX circuit to convert it to RS485. The UART can talk on a RS485 circuit if the proper electrical components are added.

Your UART code will then need to be modified to deal with RS485 transmitted data looping back in the RX/TX circuit.

0 Kudos
1,542 Views
michaelkoller
Contributor III

Magical :smileywink:

Thats exactly the info I needed. I wanted to be sure that I have to add a transceiver to the uart rx tx rts myself or if there is one obscure rs485 channel integrated into the module, you know, because of convenience or something.

I will set the TXRTSE bit (automatic flow control) in the correct uart modem register and set the polarity of the RTS signal to the required polarity of my transceiver and then it should work, right?

Now I can get on with my life, thanks.

0 Kudos
1,542 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Michael Koller

NXP provides RS485 example code for K20 product based on MQX RTOS.

Please check the default path (C:\Freescale\Freescale_MQX_4_X\mqx\examples\rs485) to find that example.

NXP MQX could be download here.


Have a great day,
Jorge Alcala

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

0 Kudos