Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

UART PIC16f877a problem

Status
Not open for further replies.

lloydi12345

Member
PIC16f877a's UART receive pin DESTROYED

Hi, I'm transmitting data from VB6 to my rf transceiver modules. I tried connecting the rx and tx pin of the rf modules and there are no problems. Everything at the start is fine. After a while the program malfunctions. I tried a lot of things to make it work again. It has been a headache to me. I'm almost done with my whole program but I'm again having a problem AGAIN on the basic transmitting and receiving part. So I went back to the basics still no hope. The data transmitted are wrong. I tried a simple program that makes the PIC send a character and VB6 accepts it exactly. I tried using another PIC16F877A and the very first program works again. I concluded then that the problem is the UART receiver pin. Can you help me how to avoid the problem again for my new PIC? Is it possible to fix my old PIC's pin? The price of this PIC is so expensive. :(
 
Last edited:
Updated the problem. Help please?

hi Lloyd,
Why do you think the PIC's RX pin is a fault.?

I have to ask... did you connect the PIC RX pin directly to the PC's TXout pin.??

You could write a short diagnostic program and set the RX [ and/or] TX pins as normal I/O and apply logic level test signals to these pins.
 
Last edited:
hi Lloyd,
Why do you think the PIC's RX pin is a fault.?

I have to ask... did you connect the PIC RX pin directly to the PC's TXout pin.??

You could write a short diagnostic program and set the RX [ and/or] TX pins as normal I/O and apply logic level test signals to these pins.

Geez, you're right ericgibbs, I tried it wired. PC>>Max232>>PIC16F877A. It works. What I hate is the transmission when RF modules are available. Okay here's my setup with wireless.
1st Side: PC>> Max232>> RF Transceiver
2nd Side: RF Transceiver>> PIC16F877a
During wireless transmission. On the 2nd side. I connected the rx and tx pin of the rf transceiver. My PC receives the appropriate characters. Now, when I let the PIC transmit back the data from the PC it wont return the right character.

Here's my code below.
Code:
unsigned char my_data;

void compare_data(void){
     switch (my_data){
       case 'f':
            uart1_write_text("Moving Clockwise_________");
            delay_ms(100);
            break;

      case 'b':
            uart1_write_text("Moving Counter-Clockwise_____");
            delay_ms(100);
            break;

      default:
            uart1_write_text("Error ");
            delay_ms(200);
            break;
     }
}

void main() {
  portc = 0;
  portd = 0;
  trisc = 0xc0;
  trisd = 0;
  adcon1 = 6;
  cmcon = 7;
  
  uart1_init(9600);
  delay_ms(300);
  
  while(1){
           if (uart1_data_ready()){
              my_data = uart1_read();
              compare_data();
           }
  }
}

It keeps on sending "Error" which is the default switch. I don't get it. Last time it works. It can receive "counter-clockwise" and "clockwise" Now it wont. I'm goin' crazy. :( I've been spending almost 2 days fixing this one. Kindly someone help me please?
 
Last edited:
hi,
Pleased to hear that part is now working OK.

I cannot help you with 'C' programming as I don't use it.

EDIT:
On this part: 2nd Side: RF Transceiver>> PIC16F877a

Are the RF out data TTL levels or RS232.????
 
Last edited:
Ericgibbs, sorry I can't get exactly what you mean. Are you asking if it's output voltage is 5v and 0v if it's TTL levels and +/-12v if it's rs232? On the 2nd side. There's only 5v and 0v operating. Here's the datasheet of my RF transceivers. Here's my RF modules by the way. https://www.electro-tech-online.com/custompdfs/2011/01/model20871.pdf I'm hoping to finish this project as soon as possible because there's an exhibit on our school 3 weeks from now so I'm taking all the necessary actions to make everything work. It's okay if you can't help me on the programming. Thank you for being part of the help :)
 
Eric is right, the setup you are using is probably wrong...this is why. When RS232 isn't doing anything it holds the TX line high, this is very bad for the TX modules as they aren't meant to send a stream of 1's.
From PC to pic RS232 is fine if you have the max232, between the TX and RX module I would maybe use a different protocol, check if your compiler has Manchester encoding routines too.
Also another side note, make sure the 2 modules aren't right next to each other :)

I remember having all this fun a year ago, good luck getting it to work!
 
Eric is right, the setup you are using is probably wrong...this is why. When RS232 isn't doing anything it holds the TX line high, this is very bad for the TX modules as they aren't meant to send a stream of 1's.
From PC to pic RS232 is fine if you have the max232, between the TX and RX module I would maybe use a different protocol, check if your compiler has Manchester encoding routines too.
Also another side note, make sure the 2 modules aren't right next to each other :)

I remember having all this fun a year ago, good luck getting it to work!

Thanks for replying birdman0_o. Yes, MikroC PRO accepts machester coding but I'm not yet that expert birdman to use manchesters. I'm even planning to use SPI, I2C interface before but I'm afraid it might take me more than a month to get everything to work.

Last week I am able to make everything work wirelessly but now I can't. I don't know if I have to place capacitors to avoid noise.
 
Last edited:
hi,
Checking with your datasheet, I expect you have the RS232 version of the module.
It reads as though the RS232 levels are TTL ie; +5V /0V, but I cannot be sure of the 'sense' of the levels.??

EDIT:

From the PIC to PC you require that MAX232 also from PC to PIC you require that MAX232, is that the way have them connected. ie; both TX and RX from the PIC to PC via a MAX232
 
Last edited:
The JZ871 is is using rs485 the pc you use rs 232 could you post how you have this hooked up
 
hi,
Checking with your datasheet, I expect you have the RS232 version of the module.
It reads as though the RS232 levels are TTL ie; +5V /0V, but I cannot be sure of the 'sense' of the levels.??

EDIT:

From the PIC to PC you require that MAX232 also from PC to PIC you require that MAX232, is that the way have them connected. ie; both TX and RX from the PIC to PC via a MAX232

Yes they are ericgibbs

The JZ871 is is using rs485 the pc you use rs 232 could you post how you have this hooked up

Hi be80be, I think there's no major problem using rs232 for the RF transceivers. This is my setup.

**broken link removed**

On the PC side:
The 12th pin of max232 is connected to the TX pin of rf transceiver.
11th pin is connected to RX pin.

On the PIC side:
TX pin of uC - Transceiver TX pin.
RX pin of uC - Transceiver RX pin.

Everything works fine now. I'm afraid I might encounter the same problem again when I disassemble everything. Here's how I'm doing it.
 
Last edited:
Eric the JZ871 is is using rs485 its high going low he has to invert his transmission
 

Attachments

  • rs485.PNG
    rs485.PNG
    33.1 KB · Views: 274
Last edited:
Everything works fine now. I'm afraid I might encounter the same problem again when I disassemble everything. Here's how I'm doing it.

hi,
I would suggest you make a note of the connections and if possible take a photograph before you disassemble.
 
I'm going by the datasheet lloydi12345 posted

JZ871 have one interface of TTL、RS232、RS485, You must specify the interface when you buy. Found that in the datasheet
 
Last edited:
I'm going by the datasheet lloydi12345 posted

JZ871 have one interface of TTL、RS232、RS485, You must specify the interface when you buy. Found that in the datasheet

This is the way I read it.

You edited your post while I was replying.
 

Attachments

  • 000esp07.gif
    000esp07.gif
    11.1 KB · Views: 271
Last edited:
I way just trying to help you got him on track looks like.

hi,
I am puzzled how it started to work.??? maybe poor connections if its only a breadboard version.??
 
Thank you ericgibbs and be80be. I'm so thankful to have two guys willing to help on solving my problem. Although I'm quite confused with table 1 the circuit for transmission works now. I had a trial and error to figure out which pin is right to achieve a successful transmission. I figured out that the problem is on 1st side, the RF Transceiver's tx pin is loose. It's not touching the breadboard. Sorry for the headache I gave to the two of you. Next time I'll encounter this problem, I'll always go for hardware connections first than going right away to my program code. Now we can show this to our exhibit which is 3 weeks away. Thank you again :)

P.S. I might still encounter problems not on PIC part since this is a big project so you still might see me posting for new threads in the succeeding days.

EDIT: Do I need to place capacitors on the RX and TX pins of the PIC? I don't have any idea about this. I've seen a lot of applications around the web and they are not using any capacitors. I've seen decoupling capacitors on Nigel's tutorial about the Wireless board. Any suggestions?
 
Last edited:
Solderless bread boards are sure not state of the art LOL. I have three I use two of them a lot one mainly a spare I got the spare out needed more space when I put 28 pin or bigger chips in they spring out. Good luck on your exhibit

Power supply lines may need some bigger capacitors but not RX and TX lines. Place across all VDD and ground close to the chips a 1uf don't hurt.
 
Status
Not open for further replies.

Latest threads

Back
Top