PIC16f877a Serial Communication with VB6

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
I have a question and it is still related to the topic. I'm doing full duplex communication. I already created my code but needed some corrections. Can I still ask question here or should I create new thread?
 

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
Thanks CDRIVE. The program should send the value placed on the 1st textbox and the 2nd textbox should show the value sent from the 1st textbox but before it shows, it passes first the value to the PIC through compim then the PIC sends the value again through compim then going back to my VB6 program. The problem is that the PIC sends this "€" on my VB6. I connected Virtual Terminals on both RX and TX wires to check if the values are correct. So far, the value sent by the VB6 to the PIC through compim is right and the only problem is the value sent back by the PIC to VB6 through compim. Here's my code in mikroc PRO:

Rich (BB code):
unsigned char my_data;

void compare_data(void){
     if (my_data == 1){
        uart1_write_text("1");
        delay_ms(200);
     }
     
     if (my_data == 0){
        uart1_write_text("0");
        delay_ms(200);
     }
     
     else
         uart1_write_text("none");
         delay_ms(200);
}

void main() {
  adcon1 = 6;
  cmcon = 7;
  
  uart1_init(9600);
  delay_ms(100);
  
  while(1){
           if (uart1_data_ready())
              my_data = uart1_read();
              compare_data();
  }
}
Here are my files below:

http://www38.zippyshare.com/v/49363989/file.html
 

CDRIVE

Joined Jul 1, 2008
2,219
I was able to unzip and view your VB files but I didn't see any obvious problems with it unless your Pic isn't sending text. I wasn't able to open your .DSN files because my Proteus is an ISIS version for Picaxe only. Please post all of your Pic code, or was that it in your last post?

Is your Pic supposed to echo back to VB (Text2.Text) the same data it received from Text1.Text?
 

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
I was able to unzip and view your VB files but I didn't see any obvious problems with it unless your Pic isn't sending text. I wasn't able to open your .DSN files because my Proteus is an ISIS version for Picaxe only. Please post all of your Pic code, or was that it in your last post?

Is your Pic supposed to echo back to VB (Text2.Text) the same data it received from Text1.Text?
Yeah it was supposed to echo it back. Anyway I got it working now CDRIVE I just changed the condition statements thank you for the help. :)
 

CDRIVE

Joined Jul 1, 2008
2,219
Yeah it was supposed to echo it back. Anyway I got it working now CDRIVE I just changed the condition statements thank you for the help. :)
Glad to hear it. BTW, just to satisfy my curiosity, where is the 'condition' statement? I didn't see it in your posted Pic code. But then...like I said, I don't know that language.
 

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
Glad to hear it. BTW, just to satisfy my curiosity, where is the 'condition' statement? I didn't see it in your posted Pic code. But then...like I said, I don't know that language.
It was this one

Rich (BB code):
void compare_data(void){
     if (my_data == 1){
        uart1_write_text("1");
        delay_ms(200);
     }
     
     if (my_data == 0){
        uart1_write_text("0");
        delay_ms(200);
     }
     
     else
         uart1_write_text("none");
         delay_ms(200);
}
I added single quote (') since characters were compared to my_data. :)
 
Last edited:
Top