PDA

View Full Version : Sharing Max232 with two pics?



zx81sp
- 23rd April 2009, 09:14
I have a board with two 16F628A and one Max233, and I want to share it with the two PICs.

Apparently it works ok but one of the PICs has been damaged (I can't reflash it), I've tried with another, first time works ok but when I try to reflash it fails (broken again).

The pics does not use the RS232 at same time for send data, and I assume that when they receive it's not problem to share the signal.

The first PIC uses a 20Mhz OSC and I'm using this code:

OUTPUT SERIAL_OUT 'make the pin an output
PAUSE 125 'don't know why, but whitout this pause does not work
SEROUT SERIAL_OUT,BPS,[126,V,"0000"] 'send data
INPUT SERIAL_OUT 'mak pin an input

The second PIC uses a internal 4Mhz OSC and don't know why, but same code does not works, so I use directly this code:

SEROUT SERIAL_OUT,BPS,[126,V,"1111"] 'send data

and this is the PIC that always end broken (it works ok, but I can't reflash it).

May be damaged because the SERIAL_OUT pin is allways output?

Luckyborg
- 23rd April 2009, 15:58
I would either switch the pin to an input when not transmitting or probably put a couple diodes in line with the 2 micros and a pull up resistor before the max233. Haven't built it, so I might have the diodes backwards.

David

Bruce
- 23rd April 2009, 21:43
Why not just use one of the OPEN baud modes? This leaves the TX pin set to input
after the transmission is complete.

zx81sp
- 24th April 2009, 07:50
Why not just use one of the OPEN baud modes? This leaves the TX pin set to input
after the transmission is complete.

With OPEN transmission does not works, nothing happens, I think that mode is for direct connection to the PC.

I'v solved the mistery of the broken PICs (just a programmer bug), anyway if someone have a better idea to share the MAX233, would be appreciated.

Thks

mister_e
- 24th April 2009, 08:43
OPEN mode work if you use a good enough pull-up resistor for true mode...

zx81sp
- 24th April 2009, 15:24
OPEN mode work if you use a good enough pull-up resistor for true mode...

I can try it, would be enough a 47k resistor?

Bruce
- 24th April 2009, 15:29
47k may work, but 4.7k to 10k will for sure.

zx81sp
- 27th April 2009, 14:37
Something does not works :(

I'm testing with another board, just a 16F628A 20mhz OSC and a MAX233 that sends 'D00000' or 'D11111' every time RB.4 changes, it works ok if I use True Mode T9600 (RB.5 connect directly to MAX233).

Try to change it to Normal Mode (N9600) modifying the board (a resistor between +5V and RB.5), but the PC receive trash:

p}ŸŸŸŸWÖÖÖÖp}ŸŸŸŸWÖÖÖÖp}ŸŸŸŸ

I've tried with several resitors (47K, 10K, 7.2K, 2.7K) with no difference.

What I'm doing wrong?

Bruce
- 27th April 2009, 14:50
What I'm doing wrong?

Trying to use inverted mode when you should be using non-inverted or TRUE mode.

You have to use TRUE mode when going through the MAX232.

zx81sp
- 27th April 2009, 15:57
Trying to use inverted mode when you should be using non-inverted or TRUE mode.

You have to use TRUE mode when going through the MAX232.

So Mister_E answer is wrong, I'm always talking about a PIC+MAX233! Without the Max I can comm with the PC (can receive from, but not send to)

Can you explain me what are the difference between inverted and non-inverted mode? When must I use each one?

Bruce
- 28th April 2009, 22:22
Can you explain me what are the difference between inverted and non-inverted mode?

It's rather self explanatory, but here's a short explanation. Inverted serial inverts each bit. I.E. if you send a 1, it's a 0. If you send a 0, it's a 1. That's what inverted means.

The PIC pin that's sending serial data, in inverted mode, will idle (fancy name for when it's not sending serial data) at logic 0.

Standard serial data (without a parity bit) consists of 10 bits. 1 start bit, 8 data bits, and 1 stop bit.

The start bit, with inverted mode, will be a logic 1. Then it sends your 8 bits of data, and ends with a stop bit. The stop bit is going to be the same as the idle logic. I.E. for inverted serial mode, the stop bit will be 1 bit time at the idle logic state of 0.

TRUE or "non inverted mode" is just the opposite logic levels.


When must I use each one?

That totally depends on the external device you're communicating with serially, and it's something you "as the designer" will need to determine.

The MAX232 is an inverter. The PC serial port expects an idle logic of 0 (this is actually -10 or more).

So, if you're going to communicate with the PC serial port, using a MAX232 RS232 converter, with a bit-banged serial command like SEROUT, you'll want to use TRUE mode with your PIC since the "idle logic" with TRUE mode is logic 1. 1 on the input of the MAX232 = 0 on the output of the MAX232 connected to the PC serial port, and that's the logic it expects during idle periods.

This is "inverted" through the MAX232, and places a -10 "or more" on the PC RX pin during idle periods.

If you had a direct connection from your PIC to the PC RX pin, like shown in your PBP manual, then you would of course use inverted to hold the PIC TX pin at logic 0 during idle periods.

In short, it's up to Y-O-U as the designer to know which mode to use based on the device you're attempting to communicate with.


So Mister_E answer is wrong

No. He was right. Maybe you just didn't understand what he was saying...;o}