UART Troubleshooting / Help - PIC16F689 + CP2102

Discussion in 'Embedded Systems and Microcontrollers' started by matrix7181, Nov 8, 2012.

  1. matrix7181

    Thread Starter New Member

    Nov 8, 2012
    9
    0
    Hello,

    I've been having some difficulties making the damn serial communication to work.
    For 3 days I couldn't sleep, eat, drink .. It's driving me crazy.
    (Slightly exaggerated, but for real, I don't know what to do anymore)

    So here is the scenario.

    I've set up and connected the PIC16F689 with CP2102 (USB to UART Bridge) and with putty I get the output from the MCU but I can't for the love of what is holy send anything to it. It just doesn't cooperate.

    Details :
    Env : MPLAB X IDE 1.50
    Programmer : PICkit3 (used to power the MCU as well, 3,3V)
    Compiler Toolchain : XC8 (v1.11)

    PIN 10 (RB7/TX/CK) connected to RX pin on CP2102
    PIN 12 (RB5/AN11/RX/DT) connected to TR on CP2102
    PIN 20 (Vss) connected to the GND on CP2102

    I don't know how to draw schematics so here is a picture (just for completeness, I don't know If you can see anything from all the wires, but maybe you will see something else that I did wrong) :

    [​IMG]

    Configuration :
    Code ( (Unknown Language)):
    1.  
    2. // CONFIG
    3. #pragma config FOSC = INTRCIO   // Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
    4. #pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
    5. #pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
    6. #pragma config MCLRE = ON       // MCLR Pin Function Select bit (MCLR pin function is MCLR)
    7. #pragma config CP = OFF         // Code Protection bit (Program memory code protection is disabled)
    8. #pragma config CPD = OFF        // Data Code Protection bit (Data memory code protection is disabled)
    9. #pragma config BOREN = ON       // Brown-out Reset Selection bits (BOR enabled)
    10. #pragma config IESO = ON        // Internal External Switchover bit (Internal External Switchover mode is enabled)
    11. #pragma config FCMEN = ON       // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is enabled)
    12.  
    Important Bits / Whats Going On / The Problem :
    Code ( (Unknown Language)):
    1.  
    2.  
    3. [B]//Set the bits / registers [/B]
    4.  
    5.     CREN = 1; //Enable Receiver
    6.     TXEN = 1; //Enable Transmitter
    7.     SPEN = 1;
    8.     TXIE = 0;  //Disable interrupts
    9.     RCIE = 0;
    10.     TX9 = 0; //Transmission Type -  8 bit (Disable 9bit comm)
    11.     RX9 = 0;
    12.     SYNC = 0; //async
    13.     BRGH = 1; //hi speed
    14.     BRG16 = 0;
    15.     SPBRG = 0x19;//Page 165 / BaudRate 9600
    16.     TXREG = 0x00;//Clear Transmit register
    17.  
    18. [B]//So Everything is set up, I hook this up to pc and get the
    19. //50x times of "Hello World \r\n"[/B]
    20.  
    21.     for(i=0;i<50;i++)
    22.         transmitMsg(greet_msg);
    23.  
    24. [B]//Then this segment[/B]
    25.  
    26.         while(!RCIF)
    27.         {
    28.             CLEAR_USART_ERRORS;
    29.         }
    30.  
    31. [B]//Just SKIPS over the first time, even though nothing is being sent
    32. //For some reason RCIF is set as the RCREG register is full / buffered.[/B]
    33.  
    34. [B]//This just makes the invalid value and all 4 LEDs light up
    35. //On the next iteration if the while(1) loop [2nd iter to be exact][/B]
    36.  
    37.         while(!RCIF) ...
    38.  
    39. [B]//Waits, and waits, and waits ....[/B]
    40.  
    I've tried the code in Stimulus, and it works as expected .. Or so I think since
    MPLABX Stimulus is a bit different from the older one in mplab 8.
    The thing is in Stimulus here I can set the register RCREG, which apparently sets the RCIF interrupt bit as well. So it executes nicely.
    However, a thing to notice is that it doesn't skip the while(!RCIF) at startup.
    Somehow I think this is "cheating" and the actual transmission on the RX pin is skipped and the only way this works on Stimulus is because im directly setting the RCREG register.

    For reference complete code :
    Code ( (Unknown Language)):
    1.  
    2. #include <stdio.h>
    3. #include <stdlib.h>
    4. #include <pic16f689.h>
    5.  
    6. #define ITER_DELAY  25000
    7.  
    8. #define LED1 0x10 //RC5
    9. #define LED2 0x01 //RC0
    10. #define LED3 0x02 //RC1
    11. #define LED4 0x08 //RC4
    12.  
    13. #define CLEAR_USART_ERRORS \
    14. if (OERR)\
    15. {\
    16.     TXEN = 0;\
    17.     TXEN = 1;\
    18.     CREN = 0;\
    19.     CREN = 1;\
    20. }\
    21. if (FERR)\
    22. {\
    23.     TXEN = 0; \
    24.     TXEN = 1; \
    25. }
    26.  
    27. void initSystem()
    28. {
    29.     //Oscilator Control
    30.     //Page 50 - IRCF -- Default 110 -> 4MHz
    31.  
    32.     //Port C - Outputs for PNP Transisedr Control (LEDs atm)
    33.     TRISC = 0x00;
    34.     PORTC = 0x00;
    35.  
    36.     /**********
    37.      * EUSART *
    38.      **********/
    39.     //AsyncMode (pg 150)
    40.     //Transmit Status And Control Register (pg 160)
    41.     //Receive Status And Control Register (pg 161)
    42.  
    43.     CREN = 1; //Enable Receiver
    44.     TXEN = 1; //Enable Transmitter
    45.     SPEN = 1;
    46.  
    47.     //Disable interrupts
    48.     TXIE = 0;
    49.     RCIE = 0;
    50.  
    51.     //Transmission Type -  8 bit (Disable 9bit comm)
    52.     TX9 = 0;
    53.     RX9 = 0;
    54.  
    55.     SYNC = 0;
    56.     BRGH = 1;
    57.     BRG16 = 0;
    58.  
    59.     //Baud Rate
    60.     SPBRG = 0x19;//Page 165 / BaudRate 9600
    61.  
    62.     //RCREG - EUART Receive Register
    63.     //TXREG - EUART Transmit Register
    64.     TXREG = 0x00;//Clear Transmit register
    65. }
    66.  
    67. void transmitMsg(register const char *msg)
    68. {
    69.     char c;
    70.     while(c = *msg++)
    71.     {
    72.         while(!TXIF)
    73.         {
    74.             CLEAR_USART_ERRORS;
    75.         }
    76.         TXREG = c;
    77.         delay();
    78.     }
    79. }
    80.  
    81. /*
    82.  * Main Program Entry
    83.  */
    84. int main(int argc, char** argv)
    85. {
    86.     initSystem();
    87.  
    88.     char greet_msg[] = "Hello World \r\n";
    89.     unsigned char tmp_rcreg = 'A';
    90.     unsigned int i = 0;
    91.  
    92.     PORTC = LED4;
    93.  
    94.     for(i=0;i<50;i++)
    95.         transmitMsg(greet_msg);
    96.  
    97.     //Bit Mask - 0001 1011
    98.     //Valid input mask (0x1B)
    99.     while(1)
    100.     {
    101.         transmitMsg("Waiting for Input : \r\n");
    102.         //Wait for some data
    103.         while(!RCIF)
    104.         {
    105.             CLEAR_USART_ERRORS;
    106.         }
    107.         tmp_rcreg = RCREG;
    108.  
    109.         if(tmp_rcreg == 'A')
    110.             PORTC = LED1;
    111.         else if(tmp_rcreg == 'B')
    112.             PORTC = LED2;
    113.         else if(tmp_rcreg == 'C')
    114.             PORTC = LED3;
    115.         else if(tmp_rcreg == 'D')
    116.             PORTC = LED4;
    117.         else
    118.             PORTC = LED1 | LED2 | LED3 | LED4;
    119.  
    120.  
    121.         //TXREG=tmp_rcreg;//tmp_rcreg;
    122.         // while(TRMT==0);//Wait till all bytes transmitted
    123.         transmitMsg(tmp_rcreg);
    124.         for(i=0;i<ITER_DELAY;i++);
    125.     }
    126.  
    127.     return (EXIT_SUCCESS);
    128. }
    129.  
    *The page # is the page from the datasheet for memo

    You can probably by now notice that I am beginner at this.
    I always liked electronics and decided it was about time to learn it.

    After reading datasheets, comparing other C code from PIC site samples, comparing assembler code from other sources and reading datasheets from those MCUs used in the examples, tried finding the similarities .. blah blah ..
    No success .. And I'm stuck :(

    So please, any advice / tips / pointers / hints / solutions are more than welcome.
     
  2. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    Since you get the hello message, the baud rate etc. is good and transmit is working.

    Have you turned all handshaking OFF on the terminal? If not, you'll have to strap RTS/CTS and DTR/DSR on the UART pins of the USB adapter to get it to send anything to the PIC. Check it by putting a DVM (or scope) on the RX pin of the PIC. It should be Vdd. Send a BREAK and the voltage should drop to 0 for the duration. You can approximate this by sending a 'U' (55h) and seeing if the pin wiggles.

    I haven't scoured your code but here are some things that jump out:

    TXREG = 0x00; does not clear TXREG, it sends 00h. Probably not your problem but..

    Its better to enable the UART TX/RX after setting up its mode, not before.

    You don't have to continually inspect FERR/OERR and neither is related to transmission. On each RXIF char received, first examine these error bits and THEN take corrective action only if set. Otherwise, just read RXBUF and continue.

    RCIF clears when RCREG is read. To avoid OERR, you must read it before the next char has been fully received. On OERR, the UART will stop receiving until the error is cleared.

    When transmitting, TXIF == 1 when you can put another char onto TXBUF to send it. You don't have to monitor TRMT unless you want to know when the last char has been shifted out (the transmitter is double buffered). The last few lines can monitor TXIF as well.

    Consider using a switch statement instead of lots of if/else.

    If you are going to add stuff after the RX gets working, consider a buffered, interrupt driven RX section to avoid missing chars while you are busy doing other things in the code.

    Have fun!
     
    Last edited: Nov 10, 2012
  3. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Start very simple by using a terminal program. Send one character from the terminal program each time. And type it in slow . Then let the PIC return it. As said before you have received a hello word message. So that mean your UART setup are OK.
     
  4. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    Just wondering if this was a typo', John? I'm not aware of any way to clear the RCIF flag manually. I thought it could only be cleared by reading RCREG...
     
    JohnInTX likes this.
  5. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,012
    Why reinvent the wheel when the Microchip UART libraries work perfectly fine?
     
  6. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    Learning how to use the library functions isn't really the same as learning how the actual hardware works, is it? That said, I think you're on the right track. Please note John's suggestions.

    If it helps, I've attached a plain vanilla Serial Demo for the little 8-pin 12F1822 written using the free/lite BoostC compiler (which I run within MPLAB).

    Cheerful regards, Mike

    Code ( (Unknown Language)):
    1. /********************************************************************
    2.  *                                                                  *
    3.  *  Project: 12F1822 Serial Demo                                    *
    4.  *   Source: 12F1822_Serial_Demo.c                                  *
    5.  *   Author: Mike McLaren, K8LH                                     *
    6.  *  (C)2012: Micro Application Consultants, All Rights Reserved     *
    7.  *     Date: 08-Jul-12                                              *
    8.  *  Revised: 08-Jul-12                                              *
    9.  *                                                                  *
    10.  *  12F1822 Serial Demo                                             *
    11.  *                                                                  *
    12.  *                                                                  *
    13.  *      IDE: MPLAB 8.84 (tabs = 4)                                  *
    14.  *     Lang: SourceBoost BoostC v7.05, Lite/Free version            *
    15.  *                                                                  *
    16.  ********************************************************************/
    17.  
    18.    #include <system.h>
    19.  
    20.    #pragma DATA _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF
    21.    #pragma DATA _CONFIG2, _LVP_OFF & _PLLEN_OFF
    22.  
    23.    #pragma CLOCK_FREQ 8000000   // 8-MHz INTOSC
    24.  
    25.   /******************************************************************
    26.    *  function prototypes                                           *
    27.    ******************************************************************/
    28.   /******************************************************************
    29.    *  type definitions                                              *
    30.    ******************************************************************/
    31.  
    32.    typedef unsigned char u08;
    33.    typedef unsigned int u16;
    34.  
    35.    #define r08 rom unsigned char
    36.  
    37.   /******************************************************************
    38.    *  variables and constants                                       *
    39.    ******************************************************************/
    40.   /******************************************************************
    41.    *  low level drivers                                             *
    42.    ******************************************************************/
    43.   /******************************************************************
    44.    *  functions                                                     *
    45.    ******************************************************************/
    46.  
    47.    char get232()                //
    48.    { while(pir1.RCIF == 0);     // wait for RX char available
    49.      return rcreg;              //
    50.    }                            //
    51.    
    52.    void put232(char txdata)     //
    53.    { while(pir1.TXIF == 0);     // wait for TX buffer empty
    54.      txreg = txdata;            //
    55.    }                            //
    56.    
    57.    void put232(rom char *data)  //
    58.    { char ndx = 0;              //
    59.      while(wreg = data[ndx++])  //
    60.        put232(wreg);            //
    61.    }                            //
    62.  
    63.   /******************************************************************
    64.    *  main init                                                     *
    65.    ******************************************************************/
    66.  
    67.    void main()
    68.    { ansela = 0;                // make pins digital
    69.      trisa = 0b00000000;        // porta all outputs
    70.      porta = 0;                 // all output latches low
    71.      osccon = 0b01110010;       // initialize 8-MHz INTOSC
    72.      while(!oscstat.HFIOFS);    // wait until OSC stable
    73.  
    74.      ansela = 0;                // adc off, digital I/O
    75.      trisa.1 = 1;               // set RX pin as input
    76.  
    77.     /*                                                              *
    78.      *  setup alternate pin functions for TX on RA0 and RX on RA1   *
    79.      *                                                              */
    80.      apfcon.RXDTSEL = 0;        // RX/DT function on RA1
    81.      apfcon.TXCKSEL = 0;        // TX/CK function on RA0
    82.  
    83.     /*                                                              *
    84.      *  setup serial port for 9600 baud (8 MHz clock)               *
    85.      *                                                              */
    86.      spbrg = 51;                // 9600 baud
    87.      baudcon.BRG16 = 0;         // use 8-bit brg clock
    88.      txsta = 1<<TXEN|1<<BRGH;   // txen=1, brgh=1, sync=0
    89.      rcsta = 1<<SPEN|1<<CREN;   // spen=1, cren=1
    90.  
    91.      delay_ms(200);             //
    92.  
    93.      put232("\n\r\n\rK8LH 12F1822 Serial Demo\n\r\n\r");
    94.  
    95.  
    96.   /******************************************************************
    97.    *  main loop                                                     *
    98.    ******************************************************************/
    99.  
    100.      while(1)                   //
    101.      { char work;               //
    102.        work = get232();         //
    103.        put232(work);            //
    104.        put232(0x0A);            //
    105.        put232(0x0D);            //
    106.      }                          //
    107.    }
    108.  
     
  7. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,012
    Maybe. But then there is having it not work with working with the hardware or having it work with the libraries. Or at the very least spending days of sleepless nights as the OP has done trying to get it to work or moving on to get the rest of your project working

    When you code for the PC, do you write to the graphics display hardware or do you use higher level calls like MS .Net?
     
  8. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    Serial port isn't so difficult, even on the hardware level, and writing a terminal program yourself.

    -Use Visual Studio. There is a serial port class: Toolbox -> Components -> Serial port.

    -Set correct handshaking on the PC side, as well take care of all serial port settings (see datasheet). You need to go through it a few times.

    -Use LEDs and piezo buzzers on all signal lines (9600 baud etc.), to verify they are actually activated.

    It should not take long until communication works.

    I have done this some years ago in assembler, but now, I use USB directly.
     
  9. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    spinnaker likes this.
  10. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,012
  11. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
  12. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,012
  13. matrix7181

    Thread Starter New Member

    Nov 8, 2012
    9
    0
    First of all I want to thank you all for your replies.

    Pattern : Quote -> Reply

    I believe so, yes.

    Code ( (Unknown Language)):
    1.  
    2. Client Settings
    3. ---------------
    4. Baud : 9600
    5. Data bits : 8
    6. Stop bits : 1
    7. Parity : None
    8. Flow Control : None
    9.  
    It doesn't wiggle. The voltage goes from 3.32 to 3.31 and, if I hold the button to 3.25

    I did the same thing when PIC was transmitting and the voltage wiggles between : 3.20 - 3.19

    I wish I had a scope to see the signal, but can't afford it.
    My voltmeter is manual, so my assumption this was a "faster" voltage test since no need to auto range the value. Or so I think, probably I'm wrong, or it doesn't have a difference.

    I need to figure out how interrupts work and how to write them in C.

    Thank you, and thanks for the suggestions, also I want to have fun .. but but .. I'm failing at these basic stuff. It's bringing my morale down.

    My project is to learn, and so making will be a success.

    I'd like to be able to write the library before using it. I have this motto of not using anything I can't program / write myself. (As in knowing how it works and being able to make it, makes it okay for me to use it)

    I downloaded Microchip Source Serial as well some other projects but, different compilers, different MCU .. :\

    That was my reference for code / logic.

    I completely agree with this for my particular case.
    Thank you for the attachment. I used it side by side comparison with my code.

    Thanks, I've already seen it. Did google quite a bit before posting here.

    So reading all replies I think maybe I know what the problem is however, I'm not sure, and if that is the case .. I will be embarrassed.

    This is the stripped down / Redone from scratch code that I'm using :

    Code ( (Unknown Language)):
    1.  
    2. #include <stdio.h>
    3. #include <stdlib.h>
    4. #include <pic16f689.h>
    5.  
    6. // CONFIG
    7. #pragma config FOSC = INTRCIO   // Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
    8. #pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
    9. #pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
    10. #pragma config MCLRE = ON       // MCLR Pin Function Select bit (MCLR pin function is MCLR)
    11. #pragma config CP = OFF         // Code Protection bit (Program memory code protection is disabled)
    12. #pragma config CPD = OFF        // Data Code Protection bit (Data memory code protection is disabled)
    13. #pragma config BOREN = ON       // Brown-out Reset Selection bits (BOR enabled)
    14. #pragma config IESO = ON        // Internal External Switchover bit (Internal External Switchover mode is enabled)
    15. #pragma config FCMEN = ON       // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is enabled)
    16.  
    17. void init()
    18. {
    19.     //Port C
    20.     TRISC = 0x00;
    21.     PORTC = 0x00;
    22.  
    23.     IRCF0 = 0;//OSCCON Register - IRCF Bits for 4MHz
    24.     IRCF1 = 1;
    25.     IRCF2 = 1;
    26.  
    27.     /**************
    28.      *    USART   *
    29.      **************/
    30.  
    31.     SPBRG = 0x19;//Page 165 / BaudRate 9600 @ 4MHz
    32.     BRGH = 1;
    33.     BRG16 = 0;
    34.    
    35.     SYNC = 0;   //Asynchronous
    36.     SPEN = 1;   //enable serial port pins
    37.     CREN=1;     //enable reception
    38.     SREN = 0;   //No effect
    39.     TXIE=0; //disable tx interrupts
    40.     RCIE=0; //disable rx interrupts
    41.     TX9 = 0;    //8-bit transmission
    42.     RX9 = 0;    //8-bit reception
    43.     TXEN=0;     //reset transmitter
    44.     TXEN=1;     //enable the transmitter
    45. }
    46.  
    47. void delay(int x)
    48. {
    49.     int c = x*1000;
    50.     while(c--);
    51. }
    52.  
    53. void transmitMsg(register const char *msg)
    54. {
    55.     char c;
    56.     while(c = *msg++)
    57.     {
    58.         while(!TXIF);
    59.         TXREG = c;
    60.         delay(2);
    61.     }
    62. }
    63.  
    64. /*
    65.  *
    66.  */
    67. int main(int argc, char** argv)
    68. {
    69.     init();
    70.     char tmp_rcreg;
    71.    
    72.     transmitMsg("Echo service started ...\r\n");
    73.  
    74.     while(1)
    75.     {
    76.         PORTC = 0x00;
    77.         transmitMsg("Input : \r\n");
    78.  
    79.         while(!RCIF);
    80.         tmp_rcreg = RCREG;
    81.  
    82.         while(!TXIF);
    83.         TXREG = tmp_rcreg;
    84.  
    85.         PORTC = 0x01;
    86.         delay(9);
    87.     }
    88.    
    89.     return (EXIT_SUCCESS);
    90. }
    91.  
    So ... Comparing all the codes I've read so far they are quite similar. And I think the problem is not in the code but in my circuit.

    Do I need to use MAX232 ?

    I've seen the MAX232 being used everywhere, and wiki tells me it translates the signal logic voltage :

    RS-232 TTL Logic
    -----------------------------------------------
    -15V ... -3V <-> +2V ... +5V <-> 1
    +3V ... +15V <-> 0V ... +0.8V <-> 0

    I assume I couldn't be able to receive the data from the PIC if I needed to use it ?

    When the USB to UART brigde is connected and I try to program the PIC MPLAB gives me this error :

    Too much current has been drawn on VDD. Please disconnect your circuit, check
    the CLK and DATA lines for shorts and then reconnect.


    I "solved" it by adding
    10k ohm resistor to TX pin on PIC
    1k ohm resistor on RX pin on PIC

    The decision was based on my basic knowledge of .. "Strap a resistor the current will go down".

    Was this ok to do ?

    Do you have any more ideas / suggestions ?
     
  14. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,012
    But your coding in C. Why not assembler? Heck don't stop there, enter the program in binary.

    We use tons of tools every day that we have no idea on the details of the way they work. If we did try to understand everything, to detail, we would never get anywhere.

    You can get the project working with the library. There is nothing that says you can't take a look a how they did it then try to repeat the library on your own later.
     
  15. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    10K is a bit high. You can also use a switch for the connection.
    1K should be enough.

    Does this PIC have a SCKP bit?
     
  16. matrix7181

    Thread Starter New Member

    Nov 8, 2012
    9
    0
    I did program in assembler before going to C.
    And of course I would gladly use the library as I said, but I can't find any for this pic, and this XC8 compiler.

    All my search got is : UART Library (mC PRO for PIC)
    Also, I don't think it's the code.
     
  17. matrix7181

    Thread Starter New Member

    Nov 8, 2012
    9
    0
    Yes.

    In BAUDCTL: BAUD RATE CONTROL REGISTER

    SCKP: Synchronous Clock Polarity Select bit

    Asynchronous mode:
    1 = Transmit inverted data to the RB7/TX/CK pin
    0 = Transmit non-inverted data to the RB7/TX/CK pin
    Synchronous mode:
    1 = Data is clocked on rising edge of the clock
    0 = Data is clocked on falling edge of the clock

    But the transmit works as intended. It's the getting data to the pic is what doesn't work.

    Also thanks for the tip, will replace it with lower value.
     
  18. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    Not exactly sure what you're ranting about but, considering the amount of energy you're using, why not throw together a working XC8 example program that we can all admire?
     
  19. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    It might be easier to write a terminal software yourself.
    So you can have more control.

    I have developed I2C, LED multiplex, LCD, and serial port circuits only with the help of LEDs, and a piezo buzzer.*

    This is very helpful to see how far signals will actually make it.

    You need to know if something arrives on the PIC RX.
    If not, there is a problem with the terminal.
    If so, your PIC software is wrong.

    *they are kind of high-Z, most clocked signals still work even with a piezo attached.
     
  20. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,012
    The microchip lib does work for most pics but I am guessing the complier could be an issue. Are you certain they don't have their own lib?


    You should try to at least afford a logic analyzer. I have a Zeroplus Logic Cube. While not the most serious LA on the market, it suits my needs and it is very affordable. It was worth it's weight in gold when I had similar serial port issues.
     
Loading...