As to the VB code, I have an open source comm project here: http://www.rof.net/yp/alphaone/activities/electronics/comm/index.html With regard to the PIC code, you might need something different, but this has worked for me as a diagnostics tool for sending values of one kind or another to the PC during PIC operation. You might note that all values are inverted - this is required for direct PIC - PC comms since there is no level shifting taking place to the correct signal voltages, which would normally invert the signal. I call the routines as shown below - cumbersum, but it works. I don't use a receive routine much - the one I have is less than perfect, so I'll leave that for you to find elsewhere, perhaps http://www.piclist.com . JB sout 'S' sout 't' sout 'r' sout 'i' sout 'n' sout 'g' sout 0x0d sout 0x0a or for hex representation: movf thevar,W call SendHexByte Here are the routines, good for 9600,N,8,1 at 4Mhz, direct to PC: sout macro thechar movlw thechar call Sendbyte endm #define serout PORTB,0 ;or whatever SendHexByte: movwf DD setpage hextab swapf DD,W call hextab call Sendbyte movf DD,W call hextab call Sendbyte return ;###################################### ;SendByte ;Send serial data at 9600/N/8/1 ;Sends byte incoming in W ;###################################### Sendbyte: movwf CC call Delay100uS ;stop bit and delay between bytes call Delay100uS call Delay100uS call Delay100uS call Delay100uS call Delay100uS call Delay100uS call Delay100uS bsf serout ;startbit 1t logic low call Delay100uS movlw D'8' movwf DD bitlp: rrf CC,f ;lsb first btfss STATUS,C goto sendlow sendhigh: bcf serout ;direct-connect so invert goto bitset sendlow: bsf serout goto bitset ;this would fall through, but ;keeps bit timing symmetrical bitset: call Delay100uS ;1t each bit decfsz DD,f goto bitlp bcf serout ;stop bit 1t logic high return hextab: andlw H'0F' ;be sure addwf PCL,f ; retlw '0' retlw '1' retlw '2' retlw '3' retlw '4' retlw '5' retlw '6' retlw '7' retlw '8' retlw '9' retlw 'a' retlw 'b' retlw 'c' retlw 'd' retlw 'e' retlw 'f' Delay100uS: movlw D'31' movwf AA lpA: decfsz AA,f goto lpA nop nop return > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Jamey Schroeder > Sent: Thursday, August 24, 2000 7:14 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: [PIC]: Serial Communications With A PC Using pic16F84A > > > Hello, > > I'm just starting to get into PIC programming and have been able > to do a few > simple projects. I'm currently trying to use a serial port of a pc to > communicate with the PIC. I'm using a 16F84A with a 4Mhz crystal. > > What I'm looking for is an example of how to send data to the pic from the > pc from within QBasic or preferably Visual Basic. I'm not very > fluent with > either language so its hard for me to break down complicated > programs. What > I'm trying to do is to light an LED based on a selection from the > computer. > For example, I would have a menu in Visual Basic that would have four > buttons and when one was pressed would cause a LED to light for a few > seconds. I understand that what I will probably need to do is send a byte > of data to the PIC and compare to some preselected values assigned to the > LED's and when a certain value is recieved turn on that LED. I just don't > know how to send a byte to the pic and have it save it into a register. > > I've found a few examples on the internet for rs232 > communications from the > pic to the pc and was able to get the message "Hello World" to > print from a > QBasic program. I haven't been able to find a example of how to send data > to a PIC. > > One other thing I was interested in is when sending data to a pc does it > always save the value in ASCII. What I mean is, what I mean is I have > purchased a 24LC64 eprom and wanted to read a value from memory > from within > the pc and have it save to a file but I want the hex saved. When > I printed > the Hello World message the PIC sends the values in hex and QBasic printed > its ASCII value. How would I get it to print the actual hex value? > > Any help would be greatly appreciated. > > Thanks in advance, > Jamey Schroeder > > -- > http://www.piclist.com hint: The PICList is archived three different > ways. See http://www.piclist.com/#archives for details. > -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.