View previous topic :: View next topic |
Author |
Message |
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
Printing out the info (printf) from your PIC using RS232 |
Posted: Mon Feb 06, 2006 1:55 pm |
|
|
The following code and example is tested successfully,,,hope it will speed up your process....
cheers
sonic
You will need additional hardware connections to your PIC to get it done... You have 2 ways you can do it,,Both ways working fine for me anyway..
Using MAX232 (mostly used I guess)
Using 2 MOFETs and 2 resistors
You can use 10K resistors in place of the 2.2K. Complete details at http://www.botkin.org/dale/rs232_interface.htm if you want to read it.
and finally here is the code for you to test...
Code: |
#include <18F2525.h>
#device ADC=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=16000000)
#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8) // Jumpers: 8 to 11, 7 to 12
void main() {
{
output_high(PIN_C4); // LED ON
printf("\r\n-----HELLO-----");
delay_ms(1000);
output_low(PIN_C4); // LED OFF
} while(TRUE)
}
|
|
|
|
pattousai
Joined: 23 Aug 2006 Posts: 37
|
|
Posted: Wed Sep 27, 2006 8:14 am |
|
|
well, i already see some example code for communication by the serial port. and i guess that you guys mean to connect the pic in the PC, am i right?
so, i always wondering, i don't need any program in the pc to do it?? i always see the pic part. its just connect to the serial port in the pc and the "hello" will show?? well, i guess not, sorry if i'm wrong.
thanks, hope that someone can help me to figure out!! |
|
|
gs
Joined: 22 Aug 2005 Posts: 30 Location: Ioannina - Greece
|
|
Posted: Wed Sep 27, 2006 4:05 pm |
|
|
You may use HyperTerminal to view the recieved data. It is in the accessories-> communications menu on you computer. Make a new connection and direct it to the com port you have your device connected _________________ www.hlektronika.gr |
|
|
pattousai
Joined: 23 Aug 2006 Posts: 37
|
|
Posted: Wed Sep 27, 2006 5:11 pm |
|
|
ahhnnn, ok. thanks!!!
humm, and if i want to do the opposite way?? send a data from the pc to the pic?? is that simple too??
thanks once again!! |
|
|
hanhao
Joined: 21 Mar 2007 Posts: 24
|
|
Posted: Mon Mar 26, 2007 2:03 am |
|
|
sadly this doesnt work for me using 687
the top graph shows the serial output at pin2 of D9 connector
the bottom graph shows the output from the chip
i used 2SK3019 NMOS
http://www.datasheetcatalog.com/datasheets_pdf/2/S/K/3/2SK3019.shtml
perhaps because i used a different schematic, i pulled R1 to high and not connected to D9 |
|
|
|