I want to implement RS485 to UART on my board. My board is based on the FRDM K64 as a reference board, so currently I'm trying to figure it out on the FRDM K64.
I've connected an RS485 to UART board to the BT connector (which equal to UART4) and from the host computer a USB to RS485 cable in this configuration:
Host computer USB -> this cable -> RS485 to uart board -> Bluetooth connector on FRDM K64 -> UART4 on MK64 chip.
Well, unfortunately, it does not work. The computer detects the USB to RS485 cable as expected, and gives it a comm port (I see it in the device manager). I connect the USB cable to the J26 connector on board the FRDM K64 to burn the flash (as always) and try to read on UART4 what I write in UART0.
Any ideas why and how to make it work?
My whole project relies on this communication.
Thanks.
Solved! Go to Solution.
Roy
I have attached a binary that will allow you to check.
1. Load it to the FRDM-K64F and connect the OpenSDA VCOM at 115200 Baud (to a terminal emulator for example)
2. Connect your BT-RS485-USB cables (connect to a terminal emulator at the same Baud rate)
3. Type in at one terminal emulator and it will appear at the other if all is OK
This will allow you to check the HW because this works on my FRDM-K64F.
Beware that BT_TX is the INPUT to the UART4 on the FRDM-K64 (and not output) and BT_TX is the output.
If it doesn't work, measure the signals and do loop-back tests with your converters and cable to identify the problem.
If it does work (HW is OK) you will need to find out why your SW isn't operating as expected.
Regards
Mark
Ok, Mark. All is working well!
I've opened 2 terminals. Each one echos to the other terminal.
Thank you very much. It means that something in my code is wrong, obviously.... and no problem with the HW.
You're a real life saver!
Thanks!!!:heart:
A few questions:
1. I'm guessing you wrote your code with your uTasker, right? As I'm not using it, I'll need to dig into my code to find what did I do wrong...
2. Is there something specific regarding UART4 I need to take care of? For example, the bus clock definition, or something else(CTS /RTS)?
3. RTS is not connected from the USB cable side. Do I need to set the register in MK64?
Roy
Yes, I always use uTasker since it can do almost everything needed without any problems (also loaders). I can simulate and so don't need to mess with HW (unless I am doing low level HW development on something for the first time).
To solve your problem I needed to add 8 lines of code and verify in the simulator that I hadn't done anything daft (first time I had, but after correcting it was OK). I can run whatever I do on more than 50 Kinetis HW so I can swap the operation between any boards within a few minutes....
The only differences between UART0/1 and 2,3,4,5 is that the first two are clocked from the system clock and the others are clocked from the bus clock so usually need different speed settings. uTasker code is generic and so I don't need to worry about that - it runs on any channel, or on any chip - with UART or LPUART. And with DMA for efficiency.
Regards
Mark
Thanks Mark. Just a few questions:
1. Flashing the bin file? Using the KDS flash icon didn't work ("c:\...\uTaskerV1.4.12_BT_UART4_Echo.bin" is not an object file: File format not recognized).
Can I drag & drop to the K20 drive in windows? (after clicking the reset while the board is powered up, etc...)?
I'm currently working with the Segger bootloader and not the MBED bootloader. Does it matter?
2. You wrote:
Beware that BT_TX is the INPUT to the UART4 on the FRDM-K64 (and not output) and BT_TX is the output.
If you could fix that typo... :smileyhappy:
Regarding this issue, the RS485 to UART board has RX & TX on the board. As I see it, the TX on this board should be connected to the RX pin in J199 bluetooth connector on the FRDM board (and vice versa). Is this what you meant? Am I right?
Thanks again. I'll check & report.
Roy
Roy
1. KDS Flash utility should work. I often use CW6.4 Flash utility too since it is easier to set u than in KDS.
The binary can be dropped onto the board using the mbed OpenSDA version - probably also works with the Segger one but I never tried it.
2. Typo: BT_RX is the OUTPUT. Yes, you need to connect your adapter's Tx to the BT_Tx.
Regards
Mark
Roy
I have attached a binary that will allow you to check.
1. Load it to the FRDM-K64F and connect the OpenSDA VCOM at 115200 Baud (to a terminal emulator for example)
2. Connect your BT-RS485-USB cables (connect to a terminal emulator at the same Baud rate)
3. Type in at one terminal emulator and it will appear at the other if all is OK
This will allow you to check the HW because this works on my FRDM-K64F.
Beware that BT_TX is the INPUT to the UART4 on the FRDM-K64 (and not output) and BT_TX is the output.
If it doesn't work, measure the signals and do loop-back tests with your converters and cable to identify the problem.
If it does work (HW is OK) you will need to find out why your SW isn't operating as expected.
Regards
Mark