PIC 16f690 UART troubles

Discussion in 'Embedded Systems and Microcontrollers' started by cheezewizz, Jul 23, 2010.

  1. cheezewizz

    Thread Starter Active Member

    Apr 16, 2009
    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...
  2. debjit625

    Well-Known Member

    Apr 17, 2010
    It may be the hardware but it seems more to be a software problem ,post your code it may have somthing wrong.

    Good Luck
  3. cheezewizz

    Thread Starter Active Member

    Apr 16, 2009
    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....
    Code ( (Unknown Language)):
    2. #include <htc.h>
    3. #include "lcd.h"
    4. #include "delay.h"
    5. #include "sci.h"
    8. void putserialstring(const char* strIn);
    9. void main(void)
    10. {
    11.     sci_Init(9600,SCI_EIGHT);
    12.     //some other guff here for lcd output
    13.     putserialstring("OK\r");    //works off and on, when it doesn't 'K\r' is what gets sent
    15.     lcd_puts("Waiting 4 serial");
    16.     lcd_goto(0x40);
    17.     lcd_puts("signal from PC");
    18.     while(1)
    19.     {
    21.         //main loop here just has code to read input from PC and update the LCD
    22.         //and this is spot on every time, only
    23.     }
    24. }
    26. void putserialstring(const char* strIn)
    27. {
    28.     while(*strIn)
    29.         sci_PutByte(*strIn++);
    30. }
    cheers for the response btw :)