Hi, when using 16F84, the user RAM begins at 0Ch, rather than at 8. Correct your ORG statement! And I guess, the carry must be inverted before sending due to the MAX232. Regards, Imre On Fri, 22 Oct 1999, Aart Arenoe wrote: > Hello, > > i want to establesh a connection between the 16F84 and the RS232 port at my co mputer. The code i use is from the application notes from techtools Chapter 3, b ut they are talking about the 16c54 in the example is there a difference for thi s usage? > Also i'm using a the max232 as shown in the example, but all there is is rubis h at my screen (good old term95). Is there somebody who did manage to get the pi c talking to the RS232? I'm using the CVASM16 assambler. It's not the computer c ause the Universal Infrared Remotecontrol works great on the same port. > Here the code..thanks for your reaction in advance! > (i'm using a 4mc christal) > Aart. > > > PROGRAM: XMIT232.SRC > ; Taken from Parallax PIC Applicaton Note: Sending RS-232 Serial Data > ; Written July 15, 1993 > ; Revised February 24, 1996 > > ; This program transmits a string of serial data. The baud rate is determined > ; by the value of the constant bit_K and the clock speed of the PIC. See the > ; table in the application note (above) for values of bit_K. For example, with > ; the clock running at 4 MHz and a desired transmitting rate of 4800 baud, > ; make bit_K 50. > > ; >>> Remember to change device info if programming a different PIC! <<< > ; Do not use RC devices. Their clock speed is not sufficiently accurate > ; or stable enough for serial communication. > > device pic16f84,xt_osc,wdt_off,protect_off ; changed the procesor type from 16c54 > ; into 16f84 > > bit_K = 24 ;24 for 9600-baud op eration @ 4 MHz > serial_out = ra.2 ;Output naar pin 1 va n IC > org 8 ;Start of availab le RAM > delay_cntr ds 1 ;Counter for serial de lay routines > bit_cntr ds 1 ;Number of transmit ted bits > msg_cntr ds 1 ;Offset in string > xmt_byte ds 1 ;The transmitted byte > org 0 ;Start of code s pace (ROM) > jmp begin ;Start Programma. > > begin mov !ra, #00000000b ;Set port to output. > mov msg_cntr, #0 ;Message string has nine characters; > ;0 through 8. > :again mov bit_cntr,#8 ;Eight bits in a byte. > mov w,msg_cntr ;Point to position in th e string. > call string ;Get the next char acter from string. > mov xmt_byte,w ;Put character into the transmit byte. > > clrb serial_out ;Change to setb ser ial_out for direct > ;connection. > > call bit_delay ;Start bit. > > :xmit rr xmt_byte ;Rotate right moves da ta bits into > ;carry, starti ng with bit 0. > > movb serial_out,c ;Change to movb serial_ out,/c for > ;direct connect ion. > > call bit_delay ;Data bit. > djnz bit_cntr,:xmit ;Not eight bits yet? S end next data bit > > setb serial_out ;Change to clrb seria l_out for direct > ;connection > > call bit_delay ;Stop bit. > inc msg_cntr ;Add one to the strin g pointer. > > cjbe msg_cntr,#8,:again > ;More characte rs to send? Go to the top > > :endless jmp :endless ;Endless loop. Reset cont roller to run > ;program. > > ; To change the baud rate, substitute a new value for bit_K at the beginning o f > ; this program. > > bit_delay mov delay_cntr,#bit_K > :loop nop > djnz delay_cntr, :loop > ret > > string jmp pc+w ;String consisting of " Parallax" > ;followed by a linefeed. > > retw 'P','a','r','a','l','l','a','x',10 > >