• AVR Freaks

Hot!Cannot set RX-TX pins for UART 2 PIC18F47K42

Author
keto
Starting Member
  • Total Posts : 58
  • Reward points : 0
  • Joined: 2018/08/28 06:30:20
  • Location: 0
  • Status: offline
2019/06/11 17:18:04 (permalink)
0

Cannot set RX-TX pins for UART 2 PIC18F47K42

Hi,
i am using pic18f47k42,when i am using the uart2 module with pins RC0 as RX and RC1 as TX the uart2 does not respond.If i change the pins e.g. RC2 as RX and RC3 as TX then the uart2 works fine.I am think that the basic function of RC0(SOSCO) and RC1(SOSCI) must be the problem,but i cannot find where to set them off.
Configurations:

// PIC18F4(5)7K42 Configuration Bit Settings

// 'C' source line config statements

// CONFIG1L
#pragma config FEXTOSC = OFF // External Oscillator Selection (Oscillator not enabled)
#pragma config RSTOSC = HFINTOSC_64MHZ// Reset Oscillator Selection (HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1)

// CONFIG1H
#pragma config CLKOUTEN = OFF // Clock out Enable bit (CLKOUT function is disabled)
#pragma config PR1WAY = ON // PRLOCKED One-Way Set Enable bit (PRLOCK bit can be cleared and set only once)
#pragma config CSWEN = OFF // Clock Switch Enable bit (The NOSC and NDIV bits cannot be changed by user software)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)

// CONFIG2L
#pragma config MCLRE = EXTMCLR // MCLR Enable bit (If LVP = 0, MCLR pin is MCLR; If LVP = 1, RE3 pin function is MCLR )
#pragma config PWRTS = PWRT_64 // Power-up timer selection bits (PWRT set at 64ms)
#pragma config MVECEN = ON // Multi-vector enable bit (Multi-vector enabled, Vector table used for interrupts)
#pragma config IVT1WAY = ON // IVTLOCK bit One-way set enable bit (IVTLOCK bit can be cleared and set only once)
#pragma config LPBOREN = OFF // Low Power BOR Enable bit (ULPBOR disabled)
#pragma config BOREN = NOSLP // Brown-out Reset Enable bits (Brown-out Reset enabled while running, disabled in Sleep; SBOREN is ignored)

// CONFIG2H
#pragma config BORV = VBOR_2P85 // Brown-out Reset Voltage Selection bits (Brown-out Reset Voltage (VBOR) set to 2.8V)
#pragma config ZCD = OFF // ZCD Disable bit (ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON)
#pragma config PPS1WAY = ON // PPSLOCK bit One-Way Set Enable bit (PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle)
#pragma config STVREN = ON // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config DEBUG = OFF // Debugger Enable bit (Background debugger disabled)
#pragma config XINST = OFF // Extended Instruction Set Enable bit (Extended Instruction Set and Indexed Addressing Mode disabled)

// CONFIG3L
#pragma config WDTCPS = WDTCPS_31// WDT Period selection bits (Divider ratio 1:65536; software control of WDTPS)
#pragma config WDTE = SWDTEN // WDT enabled/disabled by SWDTEN bit

// CONFIG3H
#pragma config WDTCWS = WDTCWS_7// WDT Window Select bits (window always open (100%); software control; keyed access not required)
#pragma config WDTCCS = SC //Software control

// CONFIG4L
#pragma config BBSIZE = BBSIZE_512// Boot Block Size selection bits (Boot Block size is 512 words)
#pragma config BBEN = OFF // Boot Block enable bit (Boot block disabled)
#pragma config SAFEN = OFF // Storage Area Flash enable bit (SAF disabled)
#pragma config WRTAPP = OFF // Application Block write protection bit (Application Block not write protected)

// CONFIG4H
#pragma config WRTB = OFF // Configuration Register Write Protection bit (Configuration registers (300000-30000Bh) not write-protected)
#pragma config WRTC = OFF // Boot Block Write Protection bit (Boot Block (000000-0007FFh) not write-protected)
#pragma config WRTD = OFF // Data EEPROM Write Protection bit (Data EEPROM not write-protected)
#pragma config WRTSAF = OFF // SAF Write protection bit (SAF not Write Protected)
#pragma config LVP = OFF // Low Voltage Programming Enable bit (HV on MCLR/VPP must be used for programming)

// CONFIG5L
#pragma config CP = OFF // PFM and Data EEPROM Code Protection bit (PFM and Data EEPROM code protection disabled)

// CONFIG5H

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

 
Initialization of the pins:
    //Configure RX/TX Pins
    TRISCbits.TRISC0 = 1; //RX
    TRISCbits.TRISC1 = 0; //TX
    ANSELCbits.ANSELC0 = 0; //Clear analog
    ANSELCbits.ANSELC1 = 0;
    U2RXPPS = 0x10; //Make RC0 as RX pin at UART2
    RC1PPS = 0x16; //Make RC1 as TX pin at UART2

#1

14 Replies Related Threads

    ric
    Super Member
    • Total Posts : 22310
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Cannot set RX-TX pins for UART 2 PIC18F47K42 2019/06/11 17:44:56 (permalink)
    0
    This setting has ambiguous definitions in the datasheet, including "reserved".

    #pragma config WDTCCS = SC //Software control

     
    Try
    #pragma config WDTCCS = LFINTOSC //WDT reference clock is the 31.0 kHz LFINTOSC
     or
    #pragma config WDTCCS = MFINTOSC //WDT reference clock is the 32kHz MFINTOSC output
     instead
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    keto
    Starting Member
    • Total Posts : 58
    • Reward points : 0
    • Joined: 2018/08/28 06:30:20
    • Location: 0
    • Status: offline
    Re: Cannot set RX-TX pins for UART 2 PIC18F47K42 2019/06/11 17:52:43 (permalink)
    0
    Thanks for the reply,
    i try them both,non of them work.But even if it work i don't understand how WDT clock selection will solve my problem.
    #3
    ric
    Super Member
    • Total Posts : 22310
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Cannot set RX-TX pins for UART 2 PIC18F47K42 2019/06/11 17:56:06 (permalink)
    +1 (1)
    keto
     i don't understand how WDT clock selection will solve my problem.

    The one setting you don't want is the one I did not mention:
    #pragma config WDTCCS = SOSC //WDT reference clock is SOSC
    as that most certainly WILL activate the secondary oscillator.
     
    Are you writing anything to the OSCEN register?
    What you need to search for is anything that activates SOSC. It's hard for us to tell when you don't post the entire program.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    keto
    Starting Member
    • Total Posts : 58
    • Reward points : 0
    • Joined: 2018/08/28 06:30:20
    • Location: 0
    • Status: offline
    Re: Cannot set RX-TX pins for UART 2 PIC18F47K42 2019/06/11 18:05:45 (permalink)
    0
    Ok here the code,missing some includes and definition but i think is understandable.
    void USART2_Init(unsigned char baud_rate){
        //Configure RX/TX Pins
        TRISCbits.TRISC0 = 1; //RX
        TRISCbits.TRISC1 = 0; //TX
        ANSELCbits.ANSELC0 = 0; //Clear analog
        ANSELCbits.ANSELC1 = 0;
        U2RXPPS = 0x10; //Make RC0 as RX pin at UART2
        RC1PPS = 0x16; //Make RC1 as TX pin at UART2
        
        //BAUD RATE --> 1 = 19200 , 2 = 57600 , 3 = 115200
        switch(baud_rate){
            case 1:
                U2BRGH = 0x03;
                U2BRGL = 0x40;
                break;
            case 2:
                U2BRGH = 0x01;
                U2BRGL = 0x14;
                break;
            case 3:
                U2BRGH = 0x00;
                U2BRGL = 0x89;
                break;
            default:
                U2BRGH = 0x00;
                U2BRGL = 0x89;
                break;
        }
        
        rx_counter2 = 0;
        
        U2CON0 = 0xB0; //Enable TX,RX,High speed baud,8-bit asynchronous
        U2CON1 = 0x00; //No send break,tx,rx output driven by shift register,wake receive off
        U2CON2 = 0x80; //Continue receive if overflow,No inverted tx,rx polarities,1 stop bit,no checksum,no handshake
        U2ERRIE = 0x00; //If errors occur during reception,continue receive and handle them as  junk characters
        U2UIR = 0x00; //Clear general interrupt flags
        PIE6bits.U2RXIE = 1; //Receive interrupt bit enable
        PIE6bits.U2TXIE =1; //Transmit interrupt bit enable
        IPR6bits.U2RXIP = 1; //Receive high priority
        IPR6bits.U2TXIP = 1; //Transmit high priority
        PIR6 = 0x00; //Clear interrupt flags
        U2CON1bits.ON = 1;
    }

    unsigned char USART2_SendByte(unsigned char byte){
        if(!PIE6bits.U2TXIE){
            tx_byte2 = byte;
            PIE6bits.U2TXIE = 1; //When we begin a transmission we make U1TXIE = 1,when we finish it we make U1TXIE=0(through interrupt routine)
            return 1;
        }
        return 0;
    }
     
    void __interrupt(irq(IRQ_U2TX)) UART2_TX_ISR(void){
        //Transmit byte for USART
        U2TXB = tx_byte2;
        PIE6bits.U2TXIE = 0;
    }

    void __interrupt(irq(IRQ_U2RX)) UART2_RX_ISR(void){
        rx_buffer2[rx_counter2] = U2RXB;
        rx_counter2 ++;
    }
     
    void main(void) {
        OSCFRQ = 0x08; //64MHz Clock defined by pragma RSTOSC,just write for sure
        OSCTUNE = 0x00; //Stable center frequency
        OSCEN = 0x40;
        while(!OSCSTATbits.HFOR && !OSCSTATbits.ADOR);
        IVTLOCK = 0x01;
            //PPS Configuration
        PPSLOCKbits.PPSLOCKED = 0; //PPS selections can change (this bit cannot change because of pragma PPS1WAY=1)

        USART2_Init(PC_BAUD_RATE);
        
        //Enable Interrupts
        INTCON0bits.IPEN = 1; //Enable interrupt priority
        INTCON0bits.GIEH = 1; //Enable high priority interrupts
        INTCON0bits.GIEL = 1; //Enable low priority interrupts
        
        //WatchDog Configuration,no Window
        WDTCON1 = 0x07; //LFINTOSC used,Windows is open at 100% of time
        WDTCON0 = 0x1B; //32 seconds watchdog time,Enable watchdog
        
        while(1){
               ....
              CLRWDT();
       }

    #5
    keto
    Starting Member
    • Total Posts : 58
    • Reward points : 0
    • Joined: 2018/08/28 06:30:20
    • Location: 0
    • Status: offline
    Re: Cannot set RX-TX pins for UART 2 PIC18F47K42 2019/06/12 13:46:42 (permalink)
    0
    Still no luck to find the solution.
    #6
    davea
    Junior Member
    • Total Posts : 114
    • Reward points : 0
    • Joined: 2016/01/28 13:12:13
    • Location: 0
    • Status: offline
    Re: Cannot set RX-TX pins for UART 2 PIC18F47K42 2019/06/12 17:36:44 (permalink)
    +1 (1)
    #pragma config PPS1WAY = ON // PPSLOCK bit One-Way Set Enable bit (PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle)
     
    set OFF
    you may have to do the unlock/lock sequence
    or move
        U2RXPPS = 0x10; //Make RC0 as RX pin at UART2
        RC1PPS = 0x16; //Make RC1 as TX pin at UART2
    before it sets lock
    #7
    Aussie Susan
    Super Member
    • Total Posts : 3562
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: Cannot set RX-TX pins for UART 2 PIC18F47K42 2019/06/12 20:57:00 (permalink)
    +2 (2)
    Also on the #pragma settings - do NOT include the DEBUG one - leave it out completely as the IDE will set that for you.
    As for the PPSLOCKED bit, davea is correct that you should set PPS1WAY to OFF (so that you can lock and unlock the PPSLOCKED bit as often as you like - at least while you get the app up and running. However the data sheet shows that the POR reset value for PPSLOCKED is 0 so that the PPS registers are unlocked by default: just don't lock them!
    When it comes to the lock and unlock sequences, they are really designed to be written in assembler as they must be executed strictly in order and without any interruption. I'm not sure about the latest compiler but some come with builtin macros that expand to the required assembler; or you can always write your own inline assembler if you want to. Just writing the equivalent in C *might* work but there is no guarantee that the compiler will not generate functionally equivalent code (which it is always allowed to do) instead of the exact instruction sequence.
    Finally, initialising the Microchip UARTs can be very tricky and you really need to stick exactly to the sequences as defined in the data sheet. I find it better to set the bit sequences in the order defined rather than trying to set the whole register at a time.
    Susan
    #8
    keto
    Starting Member
    • Total Posts : 58
    • Reward points : 0
    • Joined: 2018/08/28 06:30:20
    • Location: 0
    • Status: offline
    Re: Cannot set RX-TX pins for UART 2 PIC18F47K42 2019/06/13 13:14:15 (permalink)
    0
    Hi,thanks for the answers,does not work ether with this settings.So i remove everything and i upload my full code.This code is very simple and is only for debug this and find my wrong.Please look at it and tell me if you can spot it.I run in normal mode and in debug mode this code with breakpoint in rx isr but nothing work,not rx and not tx.
    config.h file:

    // PIC18F4(5)7K42 Configuration Bit Settings

    // 'C' source line config statements

    // CONFIG1L
    #pragma config FEXTOSC = OFF    // External Oscillator Selection (Oscillator not enabled)
    #pragma config RSTOSC = HFINTOSC_64MHZ// Reset Oscillator Selection (HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1)

    // CONFIG1H
    #pragma config CLKOUTEN = OFF   // Clock out Enable bit (CLKOUT function is disabled)
    #pragma config PR1WAY = OFF      // PRLOCKED One-Way Set Enable bit (PRLOCK bit can be cleared and set only once)
    #pragma config CSWEN = OFF      // Clock Switch Enable bit (The NOSC and NDIV bits cannot be changed by user software)
    #pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)

    // CONFIG2L
    #pragma config MCLRE = EXTMCLR  // MCLR Enable bit (If LVP = 0, MCLR pin is MCLR; If LVP = 1, RE3 pin function is MCLR )
    #pragma config PWRTS = PWRT_64  // Power-up timer selection bits (PWRT set at 64ms)
    #pragma config MVECEN = ON      // Multi-vector enable bit (Multi-vector enabled, Vector table used for interrupts)
    #pragma config IVT1WAY = ON     // IVTLOCK bit One-way set enable bit (IVTLOCK bit can be cleared and set only once)
    #pragma config LPBOREN = OFF    // Low Power BOR Enable bit (ULPBOR disabled)
    #pragma config BOREN = NOSLP    // Brown-out Reset Enable bits (Brown-out Reset enabled while running, disabled in Sleep; SBOREN is ignored)

    // CONFIG2H
    #pragma config BORV = VBOR_2P85 // Brown-out Reset Voltage Selection bits (Brown-out Reset Voltage (VBOR) set to 2.8V)
    #pragma config ZCD = OFF        // ZCD Disable bit (ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON)
    #pragma config PPS1WAY = OFF     // PPSLOCK bit One-Way Set Enable bit (PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle)
    #pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
    #pragma config XINST = OFF      // Extended Instruction Set Enable bit (Extended Instruction Set and Indexed Addressing Mode disabled)

    // CONFIG3L
    #pragma config WDTCPS = WDTCPS_31// WDT Period selection bits (Divider ratio 1:65536; software control of WDTPS)
    #pragma config WDTE = OFF  //SWDTEN  // WDT enabled/disabled by SWDTEN bit

    // CONFIG3H
    #pragma config WDTCWS = WDTCWS_7// WDT Window Select bits (window always open (100%); software control; keyed access not required)
    #pragma config WDTCCS = SC     //Software control

    // CONFIG4L
    #pragma config BBSIZE = BBSIZE_512// Boot Block Size selection bits (Boot Block size is 512 words)
    #pragma config BBEN = OFF       // Boot Block enable bit (Boot block disabled)
    #pragma config SAFEN = OFF      // Storage Area Flash enable bit (SAF disabled)
    #pragma config WRTAPP = OFF     // Application Block write protection bit (Application Block not write protected)

    // CONFIG4H
    #pragma config WRTB = OFF       // Configuration Register Write Protection bit (Configuration registers (300000-30000Bh) not write-protected)
    #pragma config WRTC = OFF       // Boot Block Write Protection bit (Boot Block (000000-0007FFh) not write-protected)
    #pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM not write-protected)
    #pragma config WRTSAF = OFF     // SAF Write protection bit (SAF not Write Protected)
    #pragma config LVP = OFF        // Low Voltage Programming Enable bit (HV on MCLR/VPP must be used for programming)

    // CONFIG5L
    #pragma config CP = OFF         // PFM and Data EEPROM Code Protection bit (PFM and Data EEPROM code protection disabled)

    // CONFIG5H

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

     
    main.c file:

    #include <xc.h>
    #include "config.h"
    #include "USART2.h"

    // This code is meant to run on a PIC running at 64 MHz.
    #define _XTAL_FREQ 64000000


    void __interrupt(irq(IRQ_U2TX)) UART2_TX_ISR(void){
        //Transmit byte for USART
        U2TXB = tx_byte2;
        PIE6bits.U2TXIE = 0;
    }

    void __interrupt(irq(IRQ_U2RX)) UART2_RX_ISR(void){
        rx_buffer2[rx_counter2] = U2RXB;
        rx_counter2 ++;
    }

    void main(void) {
        OSCFRQ = 0x08; //64MHz Clock defined by pragma RSTOSC,just write for sure
        OSCTUNE = 0x00; //Stable center frequency
        OSCEN = 0x40;
        while(!OSCSTATbits.HFOR && !OSCSTATbits.ADOR);
        
        //IVTBASE* Registers must change if we use multiple IVTs(bootloader for instance)
        /*IVTBASEU = 0x00;
        IVTBASEH = 0x00;
        IVTBASEL = 0x00;*/
        IVTLOCK = 0x01; //IVTBASE Registers are locked and cannot be written(IVTWAY=1)
        
        
        //PPS Configuration
        PPSLOCKbits.PPSLOCKED = 0; //PPS selections can change (this bit cannot change because of pragma PPS1WAY=1)
        
        USART2_Init(3);
        
        INTCON0bits.GIEH = 1; //Enable high priority interrupts
        INTCON0bits.GIEL = 1; //Enable low priority interrupts
        INTCON0bits.IPEN = 1; //Enable interrupt priority
       
        while(1){
            USART2_SendString("hi",2);
        }
    }

    USART2.c file:

    #include "USART2.h"
    #include <xc.h>

    void USART2_Init(unsigned char baud_rate){
        //Configure RX/TX Pins
        TRISCbits.TRISC0 = 0; //TX
        TRISCbits.TRISC1 = 1; //RX
        ANSELCbits.ANSELC0 = 0; //Clear analog
        ANSELCbits.ANSELC1 = 0;
        U2RXPPS = 0x11; //Make RC1 as RX pin at UART2
        RC0PPS = 0x16; //Make RC0 as TX pin at UART2

        //BAUD RATE --> 1 = 19200 , 2 = 57600 , 3 = 115200
        switch(baud_rate){
            case 1:
                U2BRGH = 0x03;
                U2BRGL = 0x40;
                break;
            case 2:
                U2BRGH = 0x01;
                U2BRGL = 0x14;
                break;
            case 3:
                U2BRGH = 0x00;
                U2BRGL = 0x89;
                break;
            default:
                U2BRGH = 0x00;
                U2BRGL = 0x89;
                break;
        }
        
        rx_counter2 = 0;
        
        U2CON0 = 0xB0; //Enable TX,RX,High speed baud,8-bit asynchronous
        U2CON1 = 0x00; //No send break,tx,rx output driven by shift register,wake receive off
        U2CON2 = 0x80; //Continue receive if overflow,No inverted tx,rx polarities,1 stop bit,no checksum,no handshake
        U2ERRIE = 0x00; //If errors occur during reception,continue receive and handle them as  junk characters
        U2UIR = 0x00; //Clear general interrupt flags
        PIE6bits.U2RXIE = 1; //Receive interrupt bit enable
        PIE6bits.U2TXIE =1; //Transmit interrupt bit enable
        IPR6bits.U2RXIP = 1; //Receive high priority
        IPR6bits.U2TXIP = 1; //Transmit high priority
        PIR6 = 0x00; //Clear interrupt flags
        U2CON1bits.ON = 1;
    }

    unsigned char USART2_SendByte(unsigned char byte){
        if(!PIE6bits.U2TXIE){
            tx_byte2 = byte;
            PIE6bits.U2TXIE = 1; //When we begin a transmission we make U1TXIE = 1,when we finish it we make U1TXIE=0(through interrupt routine)
            return 1;
        }
        return 0;
    }

    unsigned char USART2_SendString(char *str,int size){
        int attempts =3000,i;
        for(i=0;i<size;i++){
            if(!USART2_SendByte(*(str + i))){
                attempts --;
                i --; //send again the same byte
            }else{
                attempts = 3000;
            }
            if(!attempts)
                return 0;
        }
        attempts =3000;
        while(!USART2_SendByte('\r') && (attempts --)); //CR
        while(!USART2_SendByte('\n') && (attempts --)); //LF
        return 1;
    }

     
    USART.h file:

    #define RECEIVE_BUFFER_SIZE2 32


    unsigned char rx_counter2;
    unsigned char rx_buffer2[RECEIVE_BUFFER_SIZE2];
    unsigned char tx_byte2;


    void USART2_Init(unsigned char baud_rate);
    unsigned char USART2_SendByte(unsigned char data_byte);
    unsigned char USART2_SendString(char *str,int size);

     
    post edited by keto - 2019/06/13 13:17:24
    #9
    ric
    Super Member
    • Total Posts : 22310
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Cannot set RX-TX pins for UART 2 PIC18F47K42 2019/06/13 13:20:05 (permalink)
    0
    What hardware are you running this PIC on?
    Is it an evaluation board that actually does have a crystal connected to those pins?
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #10
    mbrowning
    Just a Member
    • Total Posts : 1355
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: online
    Re: Cannot set RX-TX pins for UART 2 PIC18F47K42 2019/06/13 13:30:26 (permalink)
    +4 (4)
    Port C can't be used for UART2. Study datasheet tables 17-1 and 17-2. You'll see that UART1 can connect to pins on ports B and C, but UART2 connects to ports B and D.
     

    Oh well - there's always next year
    #11
    ric
    Super Member
    • Total Posts : 22310
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Cannot set RX-TX pins for UART 2 PIC18F47K42 2019/06/13 13:34:00 (permalink)
    0
    Well spotted! :)
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #12
    keto
    Starting Member
    • Total Posts : 58
    • Reward points : 0
    • Joined: 2018/08/28 06:30:20
    • Location: 0
    • Status: offline
    Re: Cannot set RX-TX pins for UART 2 PIC18F47K42 2019/06/13 13:34:36 (permalink)
    0
    Just to add something strange.This code work fine in PIC18F27K42 and not work at PIC18F47K42,PIC18F57K42 where must be.
    #13
    keto
    Starting Member
    • Total Posts : 58
    • Reward points : 0
    • Joined: 2018/08/28 06:30:20
    • Location: 0
    • Status: offline
    Re: Cannot set RX-TX pins for UART 2 PIC18F47K42 2019/06/13 13:37:46 (permalink)
    0
    Ohhh yes....now i see the table....thank you very much!!!
     
    post edited by keto - 2019/06/13 15:19:48
    #14
    mbrowning
    Just a Member
    • Total Posts : 1355
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: online
    Re: Cannot set RX-TX pins for UART 2 PIC18F47K42 2019/06/13 13:38:35 (permalink)
    0
    That's not strange at all. 27k42 has different data in tables 17-1 and 17-2. Gotta read the datasheet (and for Microchip datasheets, hope they're accurate).

    Oh well - there's always next year
    #15
    Jump to:
    © 2019 APG vNext Commercial Version 4.5