Here is the code for software 2nd serial port by RB0 interrupt, it works in the background completely and was tested and used on PIC16F876 /*********************************************************************** **** * INTERRUPT SERVICE ROUTINES ************************************************************************ ***/ interrupt isr() { // TIMER0 ISR if(T0IF =3D=3D 1) { if(startBitFlag =3D=3D 1) // proceed only after start bit // has been received { // Read serial data=20 TMR0 =3D (byte)(255 - bitLength);// re-initialise Timer0 to // interrupt middle of next bit //(bit length is 52uSec for 19200 // Baud rate if(bitCounter < 9) // start bit not counted coz it was detected // by the interrupt { rxShift =3D (rxShift >> 1) | (RxData << 7);=09 } bitCounter++; if(bitCounter =3D=3D 9) { bitCounter =3D 0; // a byte has been received in rxShift Process it! } // RB0 INTERRUPT=20 if(INTF =3D=3D 1) if(startBitFlag =3D=3D 0) // only do if start // bit is 0 { TMR0 =3D (byte)(255 - bitLength * 1.5); // set TMR0 to // interrupt at middle // of first bit to read it T0IE =3D 1; // Enable Timer1 Interrupt INTF =3D 0; INTE =3D 0; // disable further RB0 // interrupts till stop bit occurs startBitFlag =3D 1; // we are in middle of receiving data // so enable Timer1 interrupt } // OTHER INTERRUPTS =09 if(RCIF) { // receiveBuffer =3D RCREG; // receivebufferfull =3D 1; } } -----Original Message----- From: Hubba [mailto:junk@GRYDHOLT.DK]=20 Sent: Thursday, March 21, 2002 2:22 PM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC]:Dual USART PIC > > > code available for a software UAR that uses the RB0 interrupt > > > > You might want to check out the I/O section at www.piclist.com > > There are interrupt and interruptless code samples > > > > I plan to use RB0 interrupts but can't say how soon it will > > before I have any presentable code. Still pencil-sketching > > Jinx, > I think he wants to *only* use RB0 ints to receive each "bit". This would > be impossible without using a timer, of some sort, to figure out how many > consecutive bits you didn't get an interrupt for. IIRC, if you trigger on > the start bit, you (not specifically you Jinx, but you know what I mean > ;-D) wouldn't even be guaranteed an interrupt on the stop bit. I don't see > any "feasible" way to receive serial data using *only* RB0/INT's. > > If your gonna have to use a timer anyway, then you would just use RB0/INT to > get the first bit, and TMR0 ints to trigger interrupts at the appropriate > time to receive the data bits and stop bit. If you want to retain RB0/INT for other stuff, you should be able to use RA0/T0CKI pin as described in Microchip Application note AN555. Please note that I am a newbie, so I have not tested it, nor am I sure that this pin is available on all common PICs. Best regards, Jacob Grydholt Jensen -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu