10 years, 9 months ago.

Using UART0 on FRDM-KL25Z through J1 header

I want to connect my FRDM-KL25Z board to mobile network using a 3G Arduino shield, so I had female headers soldered to the board's I/O headers. Since the MCU's UART0 can be mapped to PTA1/PTA2 pins, which in turn are connected to the board's D0/D1 Arduino pins in J1 header, I thought that I should be able to plug 3G modem directly in the KL25Z board and have the MCU communicate with it. However, I didn't realize that PTA1/PTA2 pins on the board are also connected to the OpenSDA device to allow for the virtual serial port. As result, the data sent via UART0 ends up being to delivered to the PC, and I am not seeing any response from the modem. Is there any way to use the UART0 through the Arduino pins and have the virtual serial port available at the same time? Or does the OpenSDA device need to be turned off for the communication to succeed? In the latter case, what options do I have for debugging? Thanks.

3 Answers

10 years, 9 months ago.

That is done probably because Arduino did it too. Now Arduino isn't exactly the shining example of proper design, and they actually had a reason for doing it this way (only one UART available), so I consider it not one of Freescale's best design choices. Surprisingly however I don't think Freescale really cares what I think :P.

Back to the subject, the OpenSDA part is connected via 1k resistors. So the 3G shield should be able to communicate fine with the KL25. However of course all communication from the KL25 is also sent towards your PC, and you cannot send debugging messages over it. What then is probably the saving grace: you should be able to send them via the other USB port with http://mbed.org/handbook/USBSerial

Accepted Answer

Thank you for your response and for pointing me towards USBSerial. It certainly is going to be very useful if I manage to connect to the modem via UART0. However, so far my attempts have been unsuccessful. I still cannot get correct response from the modem, even when OpenSDA is not powered. I know the modem works because I can use it successfully in standalone mode (via its own USB/serial port). I now need to find out why communication via Arduino pins is not working.

posted by Dmitriy Khodos 17 Jul 2013
10 years, 9 months ago.

I would not touch UART0 (PTA1/PTA2) and reserve them exclusively for the PC/debugging connection.. You can use one of the other serial ports for your 3G interface. (eg PTC3/PTC4 for UART1 or PTD2/PTD3 for UART2). Rewire the modem shield to use these pins.

The alternative is to disconnect the OpenSDA from PTA1/PTA2 pins and use these for the modem. You could then re-wire the OpenSDA to one of the other serial ports and use printf messages on that port for debugging. Obviously, you can also connect one of these other serial ports to a separate RS232 driver or a USB-serial converter (eg FTDI) to do some debugging without using the OpenSDA serial interface.

Thank you for your response. Are you advising against UART0 because of potential interference with OpenSDA? If so, is it still going to be an issue when OpenSDA is not connected to the PC (I managed to employ the second USB for debugging output)?

posted by Dmitriy Khodos 17 Jul 2013
10 years, 9 months ago.

OK, I switched from OpenSDA to the other USB interface for debugging output, and I reduced the UART0 baud rate to 9600. Now my KL25Z is communicating with the 3G modem, but the communication is far from being robust. A lot of characters in the modem's responses are dropped (I noticed that the drop rate increases with higher baud rate). I am using the Serial class from the "official" mbed SDK. Any suggestions on how to decrease the error rate? Thanks.