Hi Matthew... Are you sure you don't really want a DCFSNZ instead of DECFSZ here in set_tx_bit... bcf INTCON, T0IF ; Clear the interrupt flag decfsz bit_count, F <---- **** maybe you intended DCFSNZ??? **** incf state, F ; All the bits have been set, advance to the next state. Looks like maybe first time through you only send 1 bit, increment the state to 4, and bail out. -- Mark > -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu]On Behalf > Of Matthew Miller > Sent: Tuesday, May 13, 2008 9:08 PM > To: PIC List > Subject: [PIC] Help debugging a software UART routine. > > > Hi everyone, > > In the past, members of the list have been good at pointing out > programming > mistakes that I've made and I hope this time is no different. :) > > I'm trying to learn how to create a software UART which I want to be > interrupt driven. I have a transmit routine that uses delay loops written > and it works fine. My attempt at an interrupt driven transmit doesn't work > and here is the symptom: no matter what is transmitted, 0xFE is > received. The RS-232 parameters are 1200N1. > > As a guide, the interrupt driven routine is named "trasmit" and > the relevant > labels in the ISR are uart_3 and uart_4. The delay based routine is named > "transmit2" and this routine works (Coding this was my fall back after > failing to get the "transmit" routine to work.) The main loop sends a > sequence of bytes starting with '!'. > > I would be very grateful with being helped to discover my mistake(s). The > program source code is attached. > > BTW: I found out the hard way that setting the OSCCAL value is very > important for this kind of application! > > Thanks! Matthew > > -- > "With reasonable men I will reason; with humane men I will plead; but to > tyrants I will give no quarter." -- William Lloyd > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist