• AVR Freaks

Hot!UART Communication for PIC16f15324

Author
SD2019
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/02/18 09:16:16
  • Location: 0
  • Status: offline
2019/02/19 09:48:21 (permalink)
0

UART Communication for PIC16f15324

Hi, I'm new to programming pic so I'm not sure if I'm doing everything correct. I wanted to convert the code from Arduino to pic16f15324. The code works fine using Arduino nano but when I try to change to the pic, it doesn't work. I try to follow tutorials that i found online but none of them work with the pic since the tutorials use different pics and different settings for the bits. I also try to use the MCC configuration but I couldn't figure it out. The code is set up to communicate to HC-05 bluetooth and the baud rate is set to 115200.  I know you have to configure the bits settings and set up the UART communication but I'm not sure if I set it up properly since I'm using batteries to power it up. Thanks for the help.
#1

15 Replies Related Threads

    jack@kksound
    code tags!
    • Total Posts : 3188
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: UART Communication for PIC16f15324 2019/02/19 11:02:45 (permalink)
    +2 (2)
    A couple of issues: PORTA has analog capability as the default, you must clear the control bits in ANSELA to select digital mode for digital I/O to work on these pins. Also always WRITE to LATA register and READ from PORTA register.
    Change:
    PORTAbits.RA2 = x;

    to:
    LATAbits.LATA2 = x;
    This avoids possible RMW effects.
    Your CONFIG states you are using an external oscillator, is that correct?
    Your code states _XTAL_FREQ = 16000000. Is that the correct frequency?
    PORTC also has analog capability, you must clear the appropriate bits in ANSELC to select digital mode (UART MAY override this but I would not count on it).
     
    There are other possible issues but try those for now...
    #2
    SD2019
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2019/02/18 09:16:16
    • Location: 0
    • Status: offline
    Re: UART Communication for PIC16f15324 2019/02/19 11:15:35 (permalink)
    0
    The frequency is meant for 8 MHz and I didn't know if I had to use the external oscillator for the pic so I stated it to use it but I don't need it. 
    #3
    jack@kksound
    code tags!
    • Total Posts : 3188
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: UART Communication for PIC16f15324 2019/02/19 11:20:23 (permalink)
    +1 (1)
    SD2019
    The frequency is meant for 8 MHz and I didn't know if I had to use the external oscillator for the pic so I stated it to use it but I don't need it. 


    Are you then using an internal oscillator? Have you changed the CONFIG statements? IF you are using 8 Mhz why do you have 16 Mhz listed? Are you sure the pic is actually running?
     
    #4
    SD2019
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2019/02/18 09:16:16
    • Location: 0
    • Status: offline
    Re: UART Communication for PIC16f15324 2019/02/19 11:38:36 (permalink)
    0
    The pic does run because when I connect a motor to the output pin, the motor keeps on running and doesn't turn off. I did change the config statements and I meant to have it as 8 MHz but I forgot to change it in the code that I upload. Yes, I'm using the internal oscillator. How do I clear the control bits in ANSELA to select digital mode?
    #5
    jack@kksound
    code tags!
    • Total Posts : 3188
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: UART Communication for PIC16f15324 2019/02/19 11:46:15 (permalink)
    +2 (2)
    In the datasheet Section 14 - I/O PORTS read the paragraphs describing the ANSELA and ANSELC registers, it is very clear.  14.2.6 and 14.6.6 are the paragraphs.
    #6
    katela
    Super Member
    • Total Posts : 1253
    • Reward points : 0
    • Joined: 2013/06/11 05:25:18
    • Location: South Africa
    • Status: offline
    Re: UART Communication for PIC16f15324 2019/02/19 14:15:07 (permalink)
    +2 (2)
    As explained to you above, the datasheet in section 14.2.6 says: Note: The ANSELA bits default to the Analog mode after Reset. To use any pins as digital general purpose or peripheral inputs, the corresponding ANSEL bits must be initialized to ‘0’ by user software.
    ANSELA=0; // set PORTA pins as digital pins
    ANSELC=0; // set PORTC pins as digital pins
    post edited by katela - 2019/02/19 14:40:46

    Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
    YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
    #7
    SD2019
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2019/02/18 09:16:16
    • Location: 0
    • Status: offline
    Re: UART Communication for PIC16f15324 2019/02/22 11:16:41 (permalink)
    0
    I updated it and I still have issues:

    // PIC16F15324 Configuration Bit Settings

    // 'C' source line config statements

    // CONFIG1
    #pragma config FEXTOSC = OFF // External Oscillator mode selection bits (Oscillator not enabled)
    #pragma config RSTOSC = EXT1X // Power-up default value for COSC bits (EXTOSC operating per FEXTOSC bits)
    #pragma config CLKOUTEN = OFF // Clock Out Enable bit (CLKOUT function is disabled; i/o or oscillator function on OSC2)
    #pragma config CSWEN = ON // Clock Switch Enable bit (Writing to NOSC and NDIV is allowed)
    #pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable bit (FSCM timer enabled)

    // CONFIG2
    #pragma config MCLRE = ON // Master Clear Enable bit (MCLR pin is Master Clear function)
    #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
    #pragma config LPBOREN = OFF // Low-Power BOR enable bit (ULPBOR disabled)
    #pragma config BOREN = OFF // Brown-out reset enable bits (Brown-out reset disabled)
    #pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (VBOR) set to 1.9V on LF, and 2.45V on F Devices)
    #pragma config ZCD = OFF // Zero-cross detect disable (Zero-cross detect circuit is disabled at POR.)
    #pragma config PPS1WAY = ON // Peripheral Pin Select one-way control (The PPSLOCK bit can be cleared and set only once in software)
    #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable bit (Stack Overflow or Underflow will cause a reset)

    // CONFIG3
    #pragma config WDTCPS = WDTCPS_31// WDT Period Select bits (Divider ratio 1:65536; software control of WDTPS)
    #pragma config WDTE = OFF // WDT operating mode (WDT Disabled, SWDTEN is ignored)
    #pragma config WDTCWS = WDTCWS_7// WDT Window Select bits (window always open (100%); software control; keyed access not required)
    #pragma config WDTCCS = SC // WDT input clock selector (Software Control)

    // CONFIG4
    #pragma config BBSIZE = BB512 // Boot Block Size Selection bits (512 words boot block size)
    #pragma config BBEN = OFF // Boot Block Enable bit (Boot Block disabled)
    #pragma config SAFEN = OFF // SAF Enable bit (SAF disabled)
    #pragma config WRTAPP = OFF // Application Block Write Protection bit (Application Block not write protected)
    #pragma config WRTB = OFF // Boot Block Write Protection bit (Boot Block not write protected)
    #pragma config WRTC = OFF // Configuration Register Write Protection bit (Configuration Register not write protected)
    #pragma config WRTSAF = OFF // Storage Area Flash Write Protection bit (SAF not write protected)
    #pragma config LVP = OFF // Low Voltage Programming Enable bit (High Voltage on MCLR/Vpp must be used for programming)

    // CONFIG5
    #pragma config CP = OFF // UserNVM Program memory code protection bit (UserNVM code protection disabled)

    // #pragma config statements should precede project file includes.
    // Use project enums instead of #define for ON and OFF.


    #include <xc.h>
    #include <stdint.h>
    #define _XTAL_FREQ 8000000
    #define Baud 115200

    void UART_RX_Init(void);
    uint32_t UART_Buffer = 0;
    unsigned char Suit = 0x00;
    unsigned char Value = 0x00;
    int counter = 0;
    unsigned char t;
    int quotient = 0;
    int remainder = 0;
    int i= 0;
    int j=0;

    void main(void)
    {
        UART_RX_Init();
        ANSELA = 0;
        ANSELC = 0;
            
        TRISAbits.TRISA2 = 0;
        
        
        t = 0x00;
        
        while(1)
        {
            
            
            while (UART_Buffer == 0){}
            while (UART_Buffer != 0)
            {
                t = UART_Buffer;
                UART_Buffer = 0;
                      
            }
            if (UART_Buffer == 0)
            {
               if (t == 0x58)
               {
                        counter = 0;
                }
               else if (t == 0x59)
               {
                    counter = 0;
                }
               else if (t == 0x5A)
               {
               }
               else{
                    counter++;
                    Suit = t;
                    }
            if (counter == 0){
              for (int i = 0; i < 7; i++){
                    LATAbits.LATA2 = 1;
                __delay_ms(200);
                    LATAbits.LATA2 = 0;
                __delay_ms(200);
              }
            }
      
            }
            else if (counter > 0){
            counter = 0;
            Value = t;
            
             quotient = Suit/0x04;
             remainder = Suit%0x04;
          

            for (i = 0; i < quotient; i++){
              LATAbits.LATA2 = 1;
              __delay_ms(500);
              LATAbits.LATA2 = 0;
              __delay_ms(500);
            }
            for ( i = 0; i < remainder; i++){
              LATAbits.LATA2 = 1;
              __delay_ms(250);
              LATAbits.LATA2 = 0;
              __delay_ms(250);
            }
            __delay_ms(1000);
            quotient = Value/0x04;
            remainder = Value%0x04;

            for ( j = 0; j < quotient; j++){
              LATAbits.LATA2 = 1;
              __delay_ms(500);
              LATAbits.LATA2 = 0;
              __delay_ms(500);
            }
            for ( j = 0; j < remainder; j++){
              LATAbits.LATA2 = 1;
              __delay_ms(250);
              LATAbits.LATA2 = 0;
              __delay_ms(250);
            }

        }
    }
    }

    void UART_RX_Init()
    {
        SP1BRGH = 1;
        SP1BRGL = 7;
        
        TX1STAbits.SYNC = 0;
        RCSTAbits.SPEN = 1;
         
        TRISC5 = 1;
        TRISC4 = 1;
        
        RC1IE = 1;
        PEIE = 1;
        GIE = 1;
        
       RC1STAbits.CREN = 1;
    }

    void __interrupt() my_isr(void)
    {
        if (CSWIF == 1)
        {
            UART_Buffer = RCREG;
            CSWIF = 0;
        }
        
        
    }

    #8
    jack@kksound
    code tags!
    • Total Posts : 3188
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: UART Communication for PIC16f15324 2019/02/22 12:46:24 (permalink)
    +1 (1)
    SD2019
    I updated it and I still have issues:

    Specifically WHAT issues?
    #9
    SD2019
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2019/02/18 09:16:16
    • Location: 0
    • Status: offline
    Re: UART Communication for PIC16f15324 2019/02/22 13:31:35 (permalink)
    0
    The program doesn't turn the motor on when is need to be turn on. The motor keeps on running non stop. So its not communicating to the Bluetooth device properly using uart. So I'm not sure if the setting for UART_RX_Init and the interrupt is setup right. 
    #10
    jack@kksound
    code tags!
    • Total Posts : 3188
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: UART Communication for PIC16f15324 2019/02/25 10:47:29 (permalink)
    0
    From your posted code:

    #pragma config FEXTOSC = OFF // External Oscillator mode selection bits (Oscillator not enabled)
    #pragma config RSTOSC = EXT1X // Power-up default value for COSC bits (EXTOSC operating per FEXTOSC bits)

    This appears to select an EXTERNAL oscillator with the EXTERNAL OSCILLATOR circuit turned OFF yet in post#5 you state:
     Yes, I'm using the internal oscillator.

    Which is it?
    #11
    SD2019
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2019/02/18 09:16:16
    • Location: 0
    • Status: offline
    Re: UART Communication for PIC16f15324 2019/02/25 20:27:37 (permalink)
    0
    It is an internal oscillator. I didn't know what to put for some of the configuration bits settings since I'm new to programming pics so I left some of the settings as default and some were changed based on tutorials that I found.
    #12
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: UART Communication for PIC16f15324 2019/02/25 21:23:41 (permalink)
    0
    Try changing
    #pragma config RSTOSC = EXT1X // Power-up default value for COSC bits (EXTOSC operating per FEXTOSC bits)

    to
    #pragma config RSTOSC = HFINT32 // Power-up default value for COSC bits (HFINTOSC with OSCFRQ= 32 MHz and CDIV = 1:1)

    and change
    #define _XTAL_FREQ 8000000

    to
    #define _XTAL_FREQ 32000000

     
     

    Nearly there...
    #13
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: UART Communication for PIC16f15324 2019/02/25 21:45:08 (permalink)

    Nearly there...
    #14
    AMPS
    Super Member
    • Total Posts : 392
    • Reward points : 0
    • Status: offline
    Re: UART Communication for PIC16f15324 2019/02/26 02:09:17 (permalink)
    0
    Here is sample code written in pic18F24k40 with mplab x ide XC8 compiler. used to receive command are turn o LED.

     

    #include "mcc_generated_files/mcc.h"
    #define LED_RX RC7 // Pin assigned RX LED
    #define LED_TX RC6 // Pin assigned TX LED
    #define LED RC2 // Pin assigned for LED
     
    unsigned int count=0;
    char data=0;
     
    char data1[10];
    unsigned char buf[20]; //array to hold twenty bytes
     
    /* Send Data Serially */
    void send_string(const char *x)
    {
    while(*x)
    {
    EUSART_Write(*x++);
    }
    }
     

    /* Receive data as String*/
    char receive_text()
    {
    unsigned char text[10]; /*character arrya to store the string*/
    unsigned char i=0; /*array index variable */
    /*character is received until end of the string received */
    do
    {
    while(1==PIR3bits.RCIF);
    *(text+i)=RC1REG;
    i++;
    }while(*(text+i));

    return text; /* return the base address of received string */
     
     
     
    }
     
     
     
    /* Timer Interrupt Service Routine Program*/
    void Blink_Count()
    {
    if(PIR0bits.TMR0IF == 1)
    {
    PIR0bits.TMR0IF =0;
    count=count+1;
    if(count>=15)
    {
    // LED=!LED;
    count=0;

    }

    }

    }
     
     
     
     
     
     
     
    void main(void)
    {
    // Initialize the device
    SYSTEM_Initialize();
     
     
     
    send_string("Serial CHECK CODE\r\n");

    while (1)
    {
    // data= EUSART_Read();


    data= EUSART_Read();
    send_string("UART READ:");
    printf("%c \n",data);



    switch(data)

    {
    case '1': send_string("LED ON \n");
    LED=1;
    break;

    case '2':send_string("LED OFF \n");
    LED=0;
    break;

    default:send_string("Send Proper Command \n");
    break;


    }

    __delay_ms(250);
    data=0;

    }


    }
     

    pinmanger.c

     

    #include <xc.h>
    #include "pin_manager.h"
    #include "stdbool.h"
     
     
     
    void PIN_MANAGER_Initialize(void)
    {
    /**
    LATx registers
    */
    LATA = 0x00;
    LATB = 0x00;
    LATC = 0x00;
     
    /**
    TRISx registers
    */
    TRISA = 0x00;
    TRISB = 0x00;
    TRISC = 0x80;
     
    /**
    ANSELx registers
    */
    ANSELC = 0x00;
    ANSELB = 0x00;
    ANSELA = 0x00;
     
    /**
    WPUx registers
    */
    WPUE = 0x00;
    WPUB = 0x00;
    WPUA = 0x00;
    WPUC = 0x00;
     
    /**
    ODx registers
    */
    ODCONA = 0x00;
    ODCONB = 0x00;
    ODCONC = 0x00;
     




    bool state = (unsigned char)GIE;
    GIE = 0;
    PPSLOCK = 0x55;
    PPSLOCK = 0xAA;
    PPSLOCKbits.PPSLOCKED = 0x00; // unlock PPS
     
    RC6PPS = 0x09; //RC6->EUSART:TX;
    RXPPSbits.RXPPS = 0x17; //RC7->EUSART:RX;
     
    PPSLOCK = 0x55;
    PPSLOCK = 0xAA;
    PPSLOCKbits.PPSLOCKED = 0x01; // lock PPS
     
    GIE = state;
    }
     
    void PIN_MANAGER_IOC(void)
    {
     
    }
     

    esuart.c

     
    /**
    EUSART Generated Driver File
     
    @Company
    Microchip Technology Inc.
     
    @File Name
    eusart.c
     
    @Summary
    This is the generated driver implementation file for the EUSART driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs
     
    @Description
    This header file provides implementations for driver APIs for EUSART.
    Generation Information :
    Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.45
    Device : PIC18F24K40
    Driver Version : 2.00
    The generated drivers are tested against the following:
    Compiler : XC8 1.35
    MPLAB : MPLAB X 3.40
    */
     
    /*
    (c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this
    software and any derivatives exclusively with Microchip products.
     
    THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
    EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
    WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
    PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
    WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
     
    IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
    INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
    WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
    BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
    FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
    ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
    THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
     
    MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
    TERMS.
    */
     
    /**
    Section: Included Files
    */
    #include "eusart.h"
     
    /**
    Section: Macro Declarations
    */
    #define EUSART_TX_BUFFER_SIZE 8
    #define EUSART_RX_BUFFER_SIZE 8
     
    /**
    Section: Global Variables
    */
     
    volatile uint8_t eusartTxHead = 0;
    volatile uint8_t eusartTxTail = 0;
    volatile uint8_t eusartTxBuffer[EUSART_TX_BUFFER_SIZE];
    volatile uint8_t eusartTxBufferRemaining;
     
    volatile uint8_t eusartRxHead = 0;
    volatile uint8_t eusartRxTail = 0;
    volatile uint8_t eusartRxBuffer[EUSART_RX_BUFFER_SIZE];
    volatile uint8_t eusartRxCount;
     
    /**
    Section: EUSART APIs
    */
     
    void EUSART_Initialize(void)
    {
    // disable interrupts before changing states
    PIE3bits.RCIE = 0;
    PIE3bits.TXIE = 0;
     
    // Set the EUSART module to the options selected in the user interface.
     
    // ABDOVF no_overflow; SCKP Non-Inverted; BRG16 16bit_generator; WUE disabled; ABDEN disabled;
    BAUD1CON = 0x08;
     
    // SPEN enabled; RX9 8-bit; CREN enabled; ADDEN disabled; SREN enabled;
    RC1STA = 0xB0;
     
    // TX9 8-bit; TX9D 0; SENDB sync_break_complete; TXEN enabled; SYNC asynchronous; BRGH hi_speed; CSRC master;
    TX1STA = 0xA4;
     
    TRISCbits.TRISC7 = 1; //As Prescribed in Datasheet
    TRISCbits.TRISC6 = 1;
    RC1STAbits.CREN=1;
    TX1STAbits.TXEN=1;

    // Baud Rate = 9600; SP1BRGL 207;
    SP1BRGL = 0xCF;
     
    // Baud Rate = 9600; SP1BRGH 0;
    SP1BRGH = 0x00;
     

    // initializing the driver state
    eusartTxHead = 0;
    eusartTxTail = 0;
    eusartTxBufferRemaining = sizeof(eusartTxBuffer);
     
    eusartRxHead = 0;
    eusartRxTail = 0;
    eusartRxCount = 0;
     
    // enable receive interrupt
    PIE3bits.RCIE = 1;
    }
     
     
     
     
     
     
     
    uint8_t EUSART_Read(void)
    {
    uint8_t readValue = 0;

    while(0 == eusartRxCount)
    {
    }
     
    readValue = eusartRxBuffer[eusartRxTail++];
    if(sizeof(eusartRxBuffer) <= eusartRxTail)
    {
    eusartRxTail = 0;
    }
    PIE3bits.RCIE = 0;
    eusartRxCount--;
    PIE3bits.RCIE = 1;
    eusartRxBuffer[8];

    return readValue;
    }
     
    void EUSART_Write(uint8_t txData)
    {
    while(0 == eusartTxBufferRemaining)
    {
    }
     
    if(0 == PIE3bits.TXIE)
    {
    TX1REG = txData;
    }
    else
    {
    PIE3bits.TXIE = 0;
    eusartTxBuffer[eusartTxHead++] = txData;
    if(sizeof(eusartTxBuffer) <= eusartTxHead)
    {
    eusartTxHead = 0;
    }
    eusartTxBufferRemaining--;
    }
    PIE3bits.TXIE = 1;
    }
     
    char getch(void)
    {
    return EUSART_Read();
    }
     
    void putch(char txData)
    {
    EUSART_Write(txData);
    }
     
    void EUSART_Transmit_ISR(void)
    {
     
    // add your EUSART interrupt custom code
    if(sizeof(eusartTxBuffer) > eusartTxBufferRemaining)
    {
    TX1REG = eusartTxBuffer[eusartTxTail++];
    if(sizeof(eusartTxBuffer) <= eusartTxTail)
    {
    eusartTxTail = 0;
    }
    eusartTxBufferRemaining++;
    }
    else
    {
    PIE3bits.TXIE = 0;
    }
    }
     
    void EUSART_Receive_ISR(void)
    {
     
    if(1 == RC1STAbits.OERR)
    {
    // EUSART error - restart
     
    RC1STAbits.CREN = 0;
    RC1STAbits.CREN = 1;
    }
     
    // buffer overruns are ignored
    eusartRxBuffer[eusartRxHead++] = RC1REG;
    if(sizeof(eusartRxBuffer) <= eusartRxHead)
    {
    eusartRxHead = 0;
    }
    eusartRxCount++;
    }
    /**
    End of File
    */
     

     

    Amps
    *.*.*.*.*.*.*.*.*.*.*.*.*
    #15
    crosland
    Super Member
    • Total Posts : 1576
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Bucks, UK
    • Status: offline
    Re: UART Communication for PIC16f15324 2019/02/26 02:30:42 (permalink)
    0
    Where did you get these values from:
     
    void UART_RX_Init()
    {
        SP1BRGH = 1;
        SP1BRGL = 7;
     
     
    What clock frequency did you assume when calculating them for 115200 baud?
     
    What is your actual clock frequency?
     
    I think you need to study the data sheet more and also the use of config settings. Don't just blindly copy from other projects.
     
    #16
    Jump to:
    © 2019 APG vNext Commercial Version 4.5