Sharing Max232 with two pics?


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2009
    Posts
    15

    Default Sharing Max232 with two pics?

    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?

  2. #2
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86

    Default

    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
    Attached Images Attached Images

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    Why not just use one of the OPEN baud modes? This leaves the TX pin set to input
    after the transmission is complete.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Apr 2009
    Posts
    15

    Default

    Quote Originally Posted by Bruce View Post
    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

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    OPEN mode work if you use a good enough pull-up resistor for true mode...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Apr 2009
    Posts
    15

    Default

    Quote Originally Posted by mister_e View Post
    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?

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    47k may work, but 4.7k to 10k will for sure.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  8. #8
    Join Date
    Apr 2009
    Posts
    15

    Default

    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?

  9. #9
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    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.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  10. #10
    Join Date
    Apr 2009
    Posts
    15

    Default

    Quote Originally Posted by Bruce View Post
    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?
    Last edited by zx81sp; - 27th April 2009 at 16:22.

  11. #11
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    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}
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. PIC and MAX232 in/out
    By The Master in forum Serial
    Replies: 10
    Last Post: - 29th March 2008, 20:41
  2. Retrieving infos from multiple PICs on a bus/chain
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 15th October 2007, 04:42
  3. Programming Pins of PICs?
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 15th August 2007, 18:59
  4. MAX232 and DB9 connecter
    By Tomas in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 25th March 2006, 16:02
  5. Do I need MAX232 for Serial Comms
    By koossa in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 10th October 2005, 17:10

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts