RS232 comms using MAX233

25 Apr 2012

Hello MBED people, Could you help me on an RS232 comms issue please?

I’m trying to connect a MAX233 TTL-RS232 converter to pins 9 & 10. I notice that the MAX233 is a 5v device but I see on general forums that it can be used with 3.3v logic as long as the Vcc is tied to 5v. So naturally I tied this to pin 39.

I chose the MAX233 because it is a DIL chip and doesn’t require additional capacitors.

I can’t seem to get it running.

Can anyone give me some ideas please on how I might get it running, does anyone have a known-working schematic? Is the MAX233 capable of running on MBED?

Thanks

Craig

25 Apr 2012

There is a MAX3323, which is the 3 Volt version.

But might only be avalable in SMD.

some things to try:

Using something like

if (pc.readable) P910.write(pc.getchar);
if (p910.readable) pc.write(p910.getchar);

short pins 9 & 10, on MBED, and you should get what you send back.

next connect max232, short the TXD & RXD pins (+/-12V) and the same should happen.

Hope this helps

Ceri.

25 Apr 2012

Thanks Ceri,

Would I need to use an intermediate level shifter between the MBED 3.3v I/O and the MAX232. Or would a standard MAX232 do the trick alone?

I'm not understanding if any of the MAX (DIL) chips can handle 3.3 v in or out.

Cheers

Craig

25 Apr 2012

I think most I/O pins on MBED are 5Volt tollerent, But I would use a resistor, (1 to 10K) to protect your MBED.

So MAX232 can be driven from 5V :)

I will look for a 3 volt version.

Just found 9724494 In Farnell

Ceri

25 Apr 2012

Thank you Ceri

25 Apr 2012

Checkout the schematic of a Code Red development board. This board uses a MAX3232.

http://support.code-red-tech.com/CodeRedWiki/RDB1768V2Support?action=AttachFile&do=get&target=rdb1768v2r4.pdf

The MAX232 has the same pinout as the MAX3232. The only difference is that the MAX3232 needs 3V3 instead of 5V. The MAX232 works fine with mbed. No level shifters or anything needed.

Connections are:

  • mbed TX should go to one of the TIN pins on the MAX
  • mbed RX should go to one of the ROUT pins on the MAX
  • MAX TOUT goes to the TX pin 3 on a male RS232 connector
  • MAX RIN goes to the RX pin 2 on a male RS232 connector
  • connect mbed GND to pin 5 on the RS232 connector

Common problem is often that TX and RX pins are switched depending on whether you use a male or female RS232 connector. You need to use a null modem cable between two male RS232 connectors or a straight cable between male and female. Depending on terminal settings you may also have to connect DTR/DSR and RTS/CTS.

25 Apr 2012

Thank you Wim

25 Apr 2012

Hi Ceri,

I just tried that code snippet, and modified the 'getchar' to 'getc' but it still won't compile. I don't think there is a 'write' member function.

Could you help please? I'd like to accomplish this before I attached a level converter.

Thanks

Craig

25 Apr 2012

Example from Handbook on Serial: Provide a serial pass-through between the PC and an external UART

#include "mbed.h"

Serial pc(USBTX, USBRX); // tx, rx
Serial  p910(p9, p10); // tx, rx

int main() {

while(1) {
   if (pc.readable()) P910.putc(pc.getc());
   if (p910.readable()) pc.putc(p910.getc());
  }
}

25 Apr 2012

Cheers Wim,

I was just debugging that code then. I put printf hello world within the while loop and it seems to work but but only for one CR LF, then prints a continuous stream of 'd's in Hyperterminal