Hello guys, I keep sending a desperate e-mail for help from this list, and I receive the mail back, it cannot be sent. I hope this one will pass :) My problem is that I try to use the hardware usart of the 16F628, but it doesn't seem to be working. To debug the code I put some leds to blink when it is transmitting or receiving data. Only the transmit led blinks at two keypresses, and after that, no blink. The receive led never blinks, so I assume the receiving is not functioning and the transmit buffer fills up. The initialisation code is: tmp = 16UL * baud; X = (int)(XTAL/tmp) - 1; if((X>255) || (X<0)) { tmp = 64UL * baud; X = (int)(XTAL/tmp) - 1; if((X>255) || (X<0)) { return 1; /* panic - baud rate unobtainable */ } else BRGH = 0; /* low baud rate */ } else BRGH = 1; /* high baud rate */ SPBRG = X; /* set the baud rate */ SYNC = 0; /* asynchronous */ SPEN = 1; /* enable serial port pins */ CREN = 1; /* enable continuous reception */ SREN = 0; /* no effect - in asyncronous don't care*/ TXIE = 1; /* enable tx interrupts */ RCIE = 1; /* enable rx interrupts */ TX9 = ninebits?1:0; /* 8- or 9-bit transmission */ RX9 = ninebits?1:0; /* 8- or 9-bit reception */ TXEN = 1; /* enable the transmitter */ And the ISR routine: if(RCIF) { led2_on(); receivebuffer[RecvBufferPos] = sci_GetByte(); if ((++RecvBufferPos)==MAXRECEIVEBUFFER) RecvBufferPos = 0; led2_off(); } if(TXIF && TXIE) { led1_on(); if(SendBufferPos == SendBufferRecPos) TXEN = 0; else sci_PutByte(sendbuffer[SendBufferPos]); if ((++SendBufferPos)==MAXSENDBUFFER) SendBufferPos=0; led1_off(); } sci_CheckOERR(); From my point of view, the code is correct and it should function. I'm sure it is a bug somewhere and hope you can give me a hint in this direction. Thank you. Lucian Lucian ---- Home, no matter how far... http://www.home.ro -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads