Sorry, Olin, I meant TRMT, not TXMT. Anyway, I don't see any bugs. Should I be disabling TXEN and reenabling after loading TXREG? What's wrong with using the stack with calls from within an ISR? Thanks for the help! -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Hartung, Greg Sent: Thursday, July 05, 2001 9:13 AM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC]: F877 UART in ISR UART_SendChar bsf STATUS,RP0 ; switch to bank 1 btfss TXSTA,1 ; check TXMT flag and loop if goto UART_SendChar ; still not done sending the last character bcf STATUS,RP0 ; switch back to bank 0 movfw UART_Tx ; put transmit value movwf TXREG ; in transfer register return ; return from UART_SendChar -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Olin Lathrop Sent: Thursday, July 05, 2001 6:15 AM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC]: F877 UART in ISR > I have moved a call of a PUTCHAR routine from the main code to within the > ISR and now it scrambles data. I am polling TXSTA:TXMT to wait to send the > next character. Any ideas? Thanks! First, this uses an additional stack location in the interrupt, which is therefore not useable in the rest of the code. I try to avoid calls as much as possible in the interrupt routine. > UART_SendChar > bsf STATUS,RP0 > btfss TXSTA,1 > goto UART_SendChar > bcf STATUS,RP0 > movfw UART_Tx > movwf TXREG > return USE COMMENTS! I see a bug and possibly a misconception, which you probably would have seen too if you forced yourself to describe the intent of each line. Good comments don't waste time, they save time. If you don't care about your code enough to document it, then why should I bother with it? ******************************************************************** Olin Lathrop, embedded systems consultant in Littleton Massachusetts (978) 742-9014, olin@embedinc.com, http://www.embedinc.com -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu