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

Thread Starter

Cry Hart

Joined Aug 4, 2011
3
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
Rich (BB code):
void main()
{
USART_init(9600);
trisb=00000000;
portb=00000000;
while  (1)
          {
          portb.f0=1;
           if (usart_data_ready()==1)
              {
 
                 if(usart_read()=='1')
                {
                     usart_write('A');
                  }
 
              }
        }
 
 }


In real


In simulation

Use JDM Programmer





Use MAX232
(MAXIM) MAX232EPE
 

ErnieM

Joined Apr 24, 2011
8,377
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.
 

ErnieM

Joined Apr 24, 2011
8,377
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.
 

Thread Starter

Cry Hart

Joined Aug 4, 2011
3
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



 

t06afre

Joined May 11, 2009
5,934
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
 

Thread Starter

Cry Hart

Joined Aug 4, 2011
3
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
 

t06afre

Joined May 11, 2009
5,934
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
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
 
Top