Pic16f877a+uart+max232+rs232 work in simulation and dosnt work in real

Discussion in 'Embedded Systems and Microcontrollers' started by Cry Hart, Aug 4, 2011.

  1. Cry Hart

    Thread Starter New Member

    Aug 4, 2011
    3
    0
    i have problem about connect PIC16F877A with pc
    when connect microcontroller to pc using serial port and max23
    received zero
    and when i send any char received zero too
    hex works in proteus (send and receive)
    and microcontroller works
    and max232 works too

    This is the full code just to test
    Code ( (Unknown Language)):
    1. void main()
    2. {
    3. USART_init(9600);
    4. trisb=00000000;
    5. portb=00000000;
    6. while  (1)
    7.           {
    8.           portb.f0=1;
    9.            if (usart_data_ready()==1)
    10.               {
    11.  
    12.                  if(usart_read()=='1')
    13.                 {
    14.                      usart_write('A');
    15.                   }
    16.  
    17.               }
    18.         }
    19.  
    20.  }
    [​IMG]

    In real
    [​IMG]

    In simulation
    [​IMG]
    Use JDM Programmer
    [​IMG]

    [​IMG]


    Use MAX232
    (MAXIM) MAX232EPE
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,606
    Wow, very detailed first post. Very good, I like!

    Since it sims good you probably have good code (or a bad simulator). I completely like doing a simple "send "A"" over and over as a test.

    I don't see the MAX23 in the schematic. Is it a RS232 level translator? If it isn't there you need to add it to talk to the PC.


    Do you have an oscilloscope to observe signals?

    Will the JDM programmer do debugging?

    Can you also receive RS232 and light a LED if you get a correct letter? Then you can remove the computer, the MAX23, tie Tx to Rx and see if you get back what you send. When that works, do the same with the MAX23 output.

    Finally:
    The Tx of the PIC goes to Rx of the PC.
    The Rx of the PIC goes to Tx of the PC.
    They swap, sometimes in the cable, sometimes on the connector. If nothing else, swap them just to see if that is the problem.
     
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,606
    More thoughts...

    Are you sure you are actually programming the PIC? I am unfamiliar with the JDM unit, can it do a code verification of what it has loaded?

    Can you make your PIC do anything? Blink that LED you have on RB0 for example. This lets you know you have good hardware and good programming. If you can't blink that LED you need to find out why.
     
  4. Cry Hart

    Thread Starter New Member

    Aug 4, 2011
    3
    0
    Thank you for your interest
    in simulation i don't need max232 between pic and rs232
    about max232 circuit obtained from the electronics shop
    I tested it by connecting the rx to tx and found that what sent to the pic he was received in the pc
    about the program have been burned on the pic becuase led in RB0 light



     
  5. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Can you post your full schematics. It is more easy then you have the full picture. If you use electrolyte caps on the MAX232 chip. Check to see if they have the correct polarity in the circuit
     
  6. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,606
    Does that mean it is now working?
     
  7. Cry Hart

    Thread Starter New Member

    Aug 4, 2011
    3
    0
    I mean when i connect rx and tx together without pic found that what sent to the pic he was received in the pc

    Now discovered the cause of receiving zero Becuase max232 the inverse
    but still not response fro pic
     
  8. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Oh no do not mind that inverter. To make a long story short. The serial port on you PC will have some sort of RS232 to TTL level converter. That will invert your signal back, somewhat quick and dirty explained:rolleyes: So the output from the MAX232 is to be regarded as correct RS232 signals. The signal chain PIC->max232->PC(or any other RS232 equipment) is OK
     
Loading...