Hi, some points besides for GIE (Olin said it the best way): "The RCREG is a double buffered register ... [so it] can be read twice to retrieve the two bytes in the FIFO. " " ... transfers from the RSR register ... are inhibited, so it is essential to clear error bit OERR if it is set." (Cited from DS30390E, p. 108). I hope this helps. Regards, Imre +-----------------------------------------------------------------------+ | The information transmitted is intended only for the person or entity | | to which it is addressed and may contain confidential and/or | | privileged material. Any review, retransmission, dissemination or | | other use of, or taking of any action in reliance upon, this | | information by persons or entities other than the intended recipient | | is prohibited. If you received this in error, please contact the | | sender and delete the material from any computer. | +-----------------------------------------------------------------------+ On Sat, 11 Aug 2001, Andy Meng wrote: > Hello, > > I have been monitoring the PIClist for a few weeks, and decided to post > about some trouble I am having with the USART on the 16F873. I have written > some code to write to an LCD as the start of a larger project, and I am now > working on the serial communications link. I first print the initialization > message on the LCD, and send the same data out the USART to the PC at the > same time. This works fine, but I can't transmit data back to the PIC from > the PC. > > I am using a 16F873 running at 3.4MHz with a TC232 IC as the level > converter. I checked the signals going into the PIC (on RC7) with a 'scope, > and the levels appear to be fine. I am not sure about the actual bit > pattern, but by going up and down the alphabet on the keyboard I can see > binary counting going on, so I think it is sending the right data. I am > using the old "Terminal" program, but I tried Hyperterminal also. It is > running at 1200 baud. I have a troubleshooting LED that should turn on when > it enters the ISR, but it never goes on when I send it characters. Below is > the relevant part of the code: > > ------------------------------------------ > org 0 > goto Init > > org 4 > goto Interrupt > > __CONFIG _BODEN_OFF & _CP_OFF & _XT_OSC & _PWRTE_OFF & _WDT_OFF & _LVP_OFF > include "P16F873.inc" > > Interrupt: > bcf INTCON,GIE > btfss INTCON,GIE > goto $ - 2 > bsf PORTB,LED ; turn on LED > call Delay15ms > call Delay15ms > call Delay15ms > call Delay15ms > bcf PORTB,LED > btfsc PIR1,RCIF ; see if RX flag is set > call RS232_Receive ; if it is, call RS232_Receive > retfie > > org 20 > Init: > clrf INTCON ; make sure INTCON is cleared > bsf INTCON,PEIE ; turn on interrupts for peripherals > movlw 0x90 > movwf RCSTA ; turn on USART, continuous receive > bsf STATUS, RP0 ; page 1 > clrf PIE1 ; clear individual peripheral > interrupt enables > bsf PIE1,RCIE ; turn on USART RX interrupt > movlw 0x2B > movwf SPBRG ; load 1200 baud into baud rate gen > movlw 0x20 > movwf TXSTA ; turn on serial transmit enable > bcf STATUS,RP0 ; page 0 > ; the rest of the LCD init code goes below this > > RS232_Receive: ; called in ISR > movf RCREG,w ; put received data in w > movwf RXdata ; put it in RXdata reg > call LCDwrite ; write char to LCD > ;movf RXdata,w ; put data in w again > ;xorlw 0x0D ; see if enter was pressed > ;btfsc STATUS,0 ; if it was, go to next instruction > ;call ClearLCD ; clear the display > return > > ------------------------------------ > > If I am doing something wrong, please let me know what it is and how I > should change it. > > TIA, > > Andy Meng N8MX > > www.qsl.net/n8mx > > > _________________________________________________________ > Do You Yahoo!? > Get your free @yahoo.com address at http://mail.yahoo.com > > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > > > -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body