sending data to pic via max 232 by rs232 not working in proteus

Thread Starter

maxD123

Joined Dec 28, 2013
3
hi guys this is my 1st post in this forum !!
I need send data between pc and pic so i made this schematic using proteus wrote the very simple ccs c code for pic 18f2550

Rich (BB code):
#include<18f2550.h> 
#fuses NOWDT,HS,NOPROTECT,NOLVP 
#use delay(clock=20000000)
 #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,INVERT,parity=N,bits=8)   
void main() 
{     char a;
    printf("Start typing ...\n.");
    while(1)   
{
  a=getc(); 
        putc(a);   

}    
}

and my schematic is goto http://obrazki.elektroda.pl/2276196000_1388233204.jpg
and when i run the code the result is like this http://obrazki.elektroda.pl/6774018100_1388233383.jpg

so friend before this i used exsisr.c with little change

Rich (BB code):
#if defined(__PCM__)
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP 
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)   

#elif defined(__PCH__) 
#include <18F2550.h> 
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,ERRORS,INVERT)   

#elif defined(__PCD__) 
#include <30F2010.h> 
#fuses HS, NOWDT, NOPROTECT 
#use delay(clock=20000000)
#use rs232(baud=9600, UART1A)
#endif     
#define BUFFER_SIZE 32 
 
 BYTE buffer[BUFFER_SIZE];
 BYTE next_in = 0; 
 BYTE next_out = 0;

#int_rda 

void serial_isr()
 {    int t;

 buffer[next_in]=getc();    
 t=next_in;
 next_in=(next_in+1) % BUFFER_SIZE;    
 if(next_in==next_out)      
 next_in=t;           // Buffer full !! 
 
 }

#define bkbhit (next_in!=next_out)   

BYTE bgetc() 
{
BYTE c;
while(!bkbhit) ;
c=buffer[next_out];
next_out=(next_out+1) % BUFFER_SIZE;    
return(c);
}


 void main() 
{       enable_interrupts(int_rda);
   #if defined(__PCD__)    
   enable_interrupts(intr_global);    
   #else
   enable_interrupts(global);
   #endif
  printf("\r\n\Running...\r\n"); 
                 

// The program will delay for 10 seconds and then display                // any data that came in during the 10 second delay 
     do 
{       delay_ms(10000);       
  printf("\r\nBuffered data => ");
 while(bkbhit)
 putc( bgetc() );
 } while (TRUE); 
}









so proteus result for this is http://obrazki.elektroda.pl/5680434400_1388234039.jpg

SO in the both above cases i clicked on rx vir: terminal pressed keyboard buttons but they(the characters i pressed) did not appear in output terminal
if i say clearly in first case (according to my little code) i pressed keys buttons but output is like in image ("start typing" then nothing..)
in second case the long code i keep pressing keys for 10s but output like the image i added ( bufferd data..bufferd data.. as in there)

And also i Used hyperterminal with virtual serial port software in second experiment but same results came as in image..
I'm using proteus 7.8


Think u clearly got my problem and show me how to fix this...
please help me guyssss!!
thankzz
 
Last edited by a moderator:

Thread Starter

maxD123

Joined Dec 28, 2013
3
thankz for replying
now i'm using my laptop for this work and it does not have any rs232 port thats why i created virtual port using software when i work with hyperterminal.
And i have mentioned the results in my comment.
But i have pc that has com ports rs232
but i don't have other components pic and other stuff now at this moment..
I spend two days to fix this problem but unable to fix it
so what you guys suggest me to do?
 
Top