PIC 16f690 UART troubles

Thread Starter

cheezewizz

Joined Apr 16, 2009
82
Hi guys, I've built a really simple PIC circuit to send and receive some data back and forth between a PIC and my desktop PC via the serial port.
I would've attached a schematic but like I say it's very simple, just the PIC (16F690), a max232 with the 4 necessary caps, my DB9 port and that's your lot.
At the moment it works great but with one small problem, every now and again it'll not send the first byte of any byte arrays sent from the PIC to the PC. The other way round never has any problems, the data always arrives at the PIC as it started out. But every other time I power it on it will send for example just the K and the 0xd, when it should be "OK\r"....... could this have anything to do with my lack of a decoupling cap on the PICs power lines? Would appreciate any feedback, thanks a lot peeps :) Oh and for the most part, whilst it's on the breadboard it's being powered by the Pickit2...
 

Thread Starter

cheezewizz

Joined Apr 16, 2009
82
The only reason I assumed it was H/W is because it happens really sporadically, maybe every other time it's powered on. I just use the serial routines that come as sample code with hitech C and my own function to send a string rather than single chars....
Rich (BB code):
#include <htc.h>
#include "lcd.h"
#include "delay.h"
#include "sci.h"
__CONFIG(INTCLK & WDTDIS & PWRTEN & UNPROTECT);

void putserialstring(const char* strIn);
void main(void)
{
    sci_Init(9600,SCI_EIGHT);
    //some other guff here for lcd output
    putserialstring("OK\r");    //works off and on, when it doesn't 'K\r' is what gets sent
    
    lcd_puts("Waiting 4 serial");
    lcd_goto(0x40);
    lcd_puts("signal from PC");
    while(1)
    {
    
        //main loop here just has code to read input from PC and update the LCD
        //and this is spot on every time, only 
    }
}

void putserialstring(const char* strIn)
{
    while(*strIn)
        sci_PutByte(*strIn++);
}
cheers for the response btw :)
 
Top