2nd hardware UART


+ Reply to Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: 2nd hardware UART

    you don't appear to have set the portb pins used to digital [anselb =$f6]

    or not

    mcc sets the involved registers like this to match your settings

    TRISB = 0xFE;
    ANSELB = 0xF6;
    U2RXPPS = 0x0B; //RB3->UART2:RX2;
    RB0PPS = 0x16; //RB0->UART2:TX2;
    U2P1L = 0x00;
    U2P1H = 0x00;
    U2P2L = 0x00;
    U2P2H = 0x00;
    U2P3L = 0x00;
    U2P3H = 0x00;
    U2CON0 = 0xB0;
    U2CON1 = 0x80;
    U2CON2 = 0x00;
    U2BRGL = 0x82;
    U2BRGH = 0x06;
    U2FIFO = 0x00;
    U2UIR = 0x00;
    U2ERRIR = 0x00;
    U2ERRIE = 0x00;
    Last edited by richard; - 13th August 2024 at 01:05. Reason: oh you posted again when i reading the data sheet
    Warning I'm not a teacher

  2. #2
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    169


    Did you find this post helpful? Yes | No

    Default Re: 2nd hardware UART

    I'm guessing this is a reply to my 1st code post which I inadvertently cut the TRIS settings in my (hastily) attempt for reader friendly pruning, but I can assure you every port was set to digital all the time. What's more, the 2nd UART was originally configured to the same pins as the 1st. When my head was too sore from banging against that wall, I switched the 1st UART to those pins and voila, they worked.

    Troy

    Quote Originally Posted by richard View Post
    you don't appear to have set the portb pins used to digital [anselb =$f6]

    or not

    mcc sets the involved registers like this to match your settings

    TRISB = 0xFE;
    ANSELB = 0xF6;
    U2RXPPS = 0x0B; //RB3->UART2:RX2;
    RB0PPS = 0x16; //RB0->UART2:TX2;
    U2P1L = 0x00;
    U2P1H = 0x00;
    U2P2L = 0x00;
    U2P2H = 0x00;
    U2P3L = 0x00;
    U2P3H = 0x00;
    U2CON0 = 0xB0;
    U2CON1 = 0x80;
    U2CON2 = 0x00;
    U2BRGL = 0x82;
    U2BRGH = 0x06;
    U2FIFO = 0x00;
    U2UIR = 0x00;
    U2ERRIR = 0x00;
    U2ERRIE = 0x00;

Similar Threads

  1. PID-filter routine (2nd try).
    By HenrikOlsson in forum Code Examples
    Replies: 131
    Last Post: - 3rd October 2018, 07:53
  2. Setup baudrate on hardware uart on 18F4520
    By Pedro Pinto in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 25th August 2010, 00:31
  3. crucial error in a 90% working hardware uart
    By mimmmis in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 23rd September 2008, 14:18
  4. Serial Port Complete 2nd Edition
    By Bruce in forum Serial
    Replies: 4
    Last Post: - 8th November 2007, 15:28
  5. 2nd Order Digital Filter for 24-bit
    By sefayil in forum mel PIC BASIC
    Replies: 0
    Last Post: - 2nd December 2005, 21:55

Members who have read this thread : 11

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts