Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.

damayantha1991

Newbie level 2
Joined
Dec 28, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
32
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


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#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 https://obrazki.elektroda.pl/2276196000_1388233204.jpg or

and when i run the code the result is like this https://obrazki.elektroda.pl/6774018100_1388233383.jpg
or goto

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


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#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 https://obrazki.elektroda.pl/5680434400_1388234039.jpg
or goto


SO in the both above cases i clicked on rx vir: terminal pressed keyboard buttons but they(the characters i presed) 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:

Remove the max232 and directly connect the Com port to the pic. it will work
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top