• AVR Freaks

Problems with UART boot loader on PIC32MX170F256B

Page: 12 > Showing page 1 of 2
Author
VJM
Super Member
  • Total Posts : 196
  • Reward points : 0
  • Joined: 2013/04/16 10:09:35
  • Location: 0
  • Status: offline
2017/06/28 07:36:54 (permalink)
0

Problems with UART boot loader on PIC32MX170F256B

I am struggling to make the AN1388 code work for this processor, despite earlier success with a PIC32MX7XX.  It seems that the PIC is not reading the Rx pin (using UART1), despite a signal being physically present (GetChar never sees RXDA bit set...).  The hardware is fine, as I have a main programme that uses this UART with no issues.  This main programme seems to use the same setup, though I use library functions (old libraries, not Harmony) rather than direct bit addressing.
Has anyone had similar problems, or can anyone offer any advice?  I am relatively new to this forum, and have tried the search function, with no particular success.  There is no magic in the code - I am using the templates as best I can.
It is almost as though the Rx pin is not being read, or is not enabled...
 
I have uploaded three files to the server - not sure if this is the correct procedure.  The '.ld' file is saved as a 'txt' file, as this type of file is not permitted.  There are various additional calls to PutChar that I have used to check operation 0 transmission works fine on the UART.
Help!
 
#1

26 Replies Related Threads

    rodims
    Super Member
    • Total Posts : 1478
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/28 10:50:10 (permalink)
    3 (1)
    I assume you are not using or configuring secondary oscillator for your RX pin RA4.
    SOSCO/RPA4/T1CK/CTED9/PMA1/RA4
     
    from your uart.c
     
    void UartInit(UINT pbClk)
    {
    #if   (((__PIC32_FEATURE_SET__ >= 100) && (__PIC32_FEATURE_SET__ <= 299)))
            //#error("TODO: For PIC32MX1xx/PIC32MX2xx devices, user should map the UART ports to required pins using PPS");
            /* Example code
                PPSInput(2,U2RX, RPA9);  //Assign U2RX to pin RPA09
                PPSOutput(4,RPC4,U2TX);   //Assign U2TX to pin RPC4    
                //Do not forget to switch-off corresponding "analogue selection".
                ANSELx = 0;    
            */
            ANSELA = 0;
            ANSELB = 0;
        //PPSUnLock;                          // Allow PIN Mapping
            PPSOutput(1, RPA0, U1TX);       // MAP UART1 Tx to PA0
            PPSInput (3, U1RX, RPA4);       // MAP UART1 Rx to PA4
        //PPSLock;                  // Prevent Accidental Mapping
    #endif
        // Open UART1 with Receive and Transmitter enable.
        U1BRG = (pbClk/16/DEFAULT_BAUDRATE-1); // calculate actual BAUD generate value.
        U1MODE = UART_EN;
        U1STA = (UART_RX_ENABLE | UART_TX_ENABLE);    

     
    I'm lacking experience with this pps.h macro, especially the first 'grp' parameter. 
    But the include says that  U1RX belongs to 'group 1'  (not 3)
     
    PPSInput (3, U1RX, RPA4);       // MAP UART1 Rx to PA4
     
    from pps.h

     
    /* Input Pins Group 1 */
    #define IN_FN_PPS1_INT3          INT3Rbits.INT3R
    #define IN_FN_PPS1_T2CK          T2CKRbits.T2CKR
    #define IN_FN_PPS1_IC3           IC3Rbits.IC3R
    #define IN_FN_PPS1_U1RX          U1RXRbits.U1RXR
    #define IN_FN_PPS1_U2RX          U2RXRbits.U2RXR
    #define IN_FN_PPS1_U5CTS         U5CTSRbits.U5CTSR
    #define IN_FN_PPS1_REFCLKI       REFCLKIRbits.REFCLKIR
     

     
    If that's not the problem,- can you succesfully SEND data with PutChar via TX pin ?
    #2
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/28 12:28:04 (permalink)
    0
    Dear Rodims,
    Thank you for your reply.
    I have just found a note in the I/O Port section of the PIC32 manual that indicates that you also need to set the TRIS for the port pin to input as well as using the PPSInput definition (actually in DS60001 168J p129 figure 11-2).  I am about to try this when I get back to the lab, but it would explain the symptoms, so I am hopeful.  I will respond when I have checked.
    IF this is the case, it is really annoying, as the example does not mention this requirement.  This is the first PIC32 that I have used with the PPS facility...  Needless to say, the UART section does not mention this requirement.
    To answer your points, I am not using the secondary oscillator, and I can successfully SEND with the Tx pin.  The problem is with the receive, and the symptoms are that the data on the pin did not seem to be read.  If I have to set the TRIS pin to input, then this would explain the problem.
    I'll post a reply when I have performed the test.
    Many thanks again.
    #3
    rodims
    Super Member
    • Total Posts : 1478
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/28 12:51:47 (permalink)
    0
    I agree, the figure 11-2 is very clear in this point.
    It will not work without setting TRIS to input.
    #4
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/28 12:53:23 (permalink)
    0
    I have just tested this theory, and it did not seem to work...  I have tried:
    TRISAbits.TRISA4 = 1;
    and alternatively
     mPORTASetPinsDigitalIn(BIT_4);   //Set portA4 as input
    with no success; I can still print output from the UART1, but it ignores input (from RealTerm set to match the UART parameters).
    The alternative setup that I use successfully in the main program is (parameters are correct, but not shared here):
    /******************************************************************************/
    void SetupPorts( void )
    {
    //set up the various port bits as required
        PPSUnLock;                          // Allow PIN Mapping
            PPSOutput(1, RPA0, U1TX);       // MAP UART1 Tx to PA0
            //PPSOutput(4, RPB10, U2TX);      // MAP UART2 Tx to PB10
            PPSOutput(2, RPB1, SDO2);      // MAP SDO2 to PB1
            //PPSOutput(4, RPB0, NULL);      // MAP PB0 to GPIO
            //PPSOutput(1, RPB4, NULL);      // MAP PB4 to GPIO
            PPSInput (3, U1RX, RPA4);       // MAP UART1 Rx to PA4
            //PPSInput (2, U2RX, RPB11);      // MAP UART2 Rx to PB11
            PPSInput (3, SDI2, RPB6);       // MAP SDI2 to PB6
            //PPSOutput(3, RPB13, REFCLKO);
        PPSLock;                  // Prevent Accidental Mapping 
      
        mPORTBClearBits (BIT_1);       //SDO2 set low at start
        mPORTBSetBits (BIT_7);         //Set bit to clear reset of MCP23017
        mPORTBSetBits (BIT_12);        //RB12 (CS_DAC Exh) set high at start
        mPORTBSetBits (BIT_13);        //RB13 (CS_DAC) set high at start; not now SDO1
        mPORTBSetBits (BIT_14);        //RB14 (CS_ADC) set high at start; not now SCK1
        mPORTBSetBits (BIT_15);        //SCK2 set at start
        //mPORTBClearBits (BIT_6);       //Clear bits to disable RS-485 transmitter.
        mPORTBSetPinsDigitalOut(BIT_1|BIT_7|BIT_12|BIT_13|BIT_14|BIT_15);   //Set portB1/7/12/13/14/15 as output
        mPORTBSetPinsDigitalIn(BIT_0|BIT_4|BIT_5|BIT_6);   //Set portB0/4/5/6 as input
        mPORTASetPinsDigitalIn(BIT_1);   //Set portA1 as input
    }
    /******************************************************************************/
    void SetupSerialLines ( void )
    {
        char        buf[100] = "Caleta Technologies Ltd \r\nPlease Wait...\r\n";
        UART_LINE_STATUS lineStatus;
        int             ClockValue;
       
        UARTConfigure ( UARTM, UARTM_CONFIGURATION );
        actualDataRate = UARTSetDataRate(UARTM, PERIPHERAL_CLOCK, DESIRED_DATA_RATE);
        UARTSetLineControl ( UARTM, UARTM_LINE_CONTROL );
        UARTEnable ( UARTM, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX) );
        SendDataBuffer( DIAGPORT, buf, strlen(buf));      //initial message
           
        lineStatus = UARTGetLineStatus(UART1);
        sprintf(buf, "Clock = %u, Line Status = %x \r\n", actualDataRate, lineStatus );  
        SendDataBuffer( DIAGPORT, buf, strlen(buf));   
        if ( (UART_PARITY_ERROR|UART_FRAMING_ERROR|UART_OVERRUN_ERROR) & lineStatus )
            errorreport ( MAIN_SECTION, 2, 0);
        sprintf(buf, "Caleta Technologies Ltd : PID Controller\r\n");  
        SendDataBuffer( DIAGPORT, buf, strlen(buf));      //initial message 
    //Now initialise the various I2C and SPI parallel port devices
        ClockValue = I2C_Init();     //set up the internal I2C bus for use
        sprintf(buf, "I2C clock = %i\r\n", ClockValue);  
        SendDataBuffer( DIAGPORT, buf, strlen(buf));      //initial message 
        portused = DIAGPORT;   
      
        //I2CEnable ( I2C_BUS, TRUE );
        //I2C_BBSoftware_Reset_Sequence( I2C_BUS );  //<-seems to cause issues?
        //I2CEnable ( I2C_BUS, FALSE );
        sprintf(buf, "I2C line reset\r\n");  
        SendDataBuffer( DIAGPORT, buf, strlen(buf));      //initial message
       
        SpiInitDevice(SPI_CHANNEL2, 1, 0, 0);   // Initialize the SPI channel 2 as master, frame master
        sprintf(buf, "SPI Channel 2 initialised\r\n");  
        SendDataBuffer( DIAGPORT, buf, strlen(buf));      //initial message   
    }
    so I am totally confused at present...
    Thank you again for considering this issue - very stuck at the moment!  I thought that I had it when I spotted that comment, but it seems not to be so.
    #5
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/28 13:12:02 (permalink)
    0
    On thinking about it, the TRIS register should be set to input after a reset (default condition), so it should be in the correct state for the UART and not need setting specifically. 
    It still looks as though the pin is not being read.  Transmit continues to work fine!  Back to being confused...
    #6
    rodims
    Super Member
    • Total Posts : 1478
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/28 13:16:19 (permalink)
    4 (1)
    Please use code tags for code
    i.e.
    [ c o d e ]
    myfunc();
    [ / c o d e ]
    but remove all the blanks inside the brackets.
     
    Still setting
    TRISAbits.TRISA4 = 1;
    is required, so you have one bug less.
    What is not clear to me, why does your main application run without that ?
    Is your main application run by a bootloader or is it run without bootloader ?
     
    If this
      PPSInput (3, U1RX, RPA4);       // MAP UART1 Rx to PA4
    works in your main program (application) the '3' likely is not a problem, but as said, I do not know what this first 'grp' macro argument actually does.
     
    Will not be able to have a closer look the next 12 hours ...
     
    #7
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/28 22:19:16 (permalink)
    0
    Dear Rodims,
    Thank you for your comments.  I will try to use the tags as you suggest - I do not use this forum regularly...
    The reset state, whereby all ports are initialised to inputs, should explain why the main code works correctly.  I am always surprised that analogue inputs are reset to on, but so be it.  The main application is being loaded using a PICKit3 and works well;  I am now moving on to the serial boot-loaded version to permit field upgrades - hence this problem!  I normally use the PIC32MX795 with no issues; this is my first experience with a PIC32MX1XX, and the associated PPS functionality.
    I will try the UART setup in the main programme, or possibly take the boot code out of the boot-loader and set it up as a 'normal' programme under the PICKit3.  I will keep you posted, but I remain confused.  the problem is likely to be somewhere else completely, but this is a very simple boot-loader (except for the memory mapping, which I have copied from the templates, but tried to understand more fully).
    Best wishes
    #8
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/28 22:25:08 (permalink)
    3 (1)
    VJM345
    ...
    I am always surprised that analogue inputs are reset to on, but so be it. 

    Don't be surprised.
    That is the safest approach, and all PICs do it.
    You can safely feed a digital signal into an analog pin, but an analog signal into a digital pin is out of spec.
    So, all pins which might be analog start off in that mode, and it's your job to switch them to digital mode as required.
     
    n.b. You're actually switching digital mode ON, not analog mode OFF.
    In reality, the analog input is always active, and you are enabling the digital input buffer when you switch to digital mode.
     
     
    #9
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/28 23:07:20 (permalink)
    3 (1)
    Dear qhb,
    Your points make sense, thank you.  I very seldom, if ever, use the analogue capabilities in the PIC32 as they are not accurate enough for my applications; I always have external DAC/ADCs.  Hence my comment (not having thought it through...)!
    Do you have any advice on my current problem?  I hope to test the setup in other modes shortly...
    Best wishes
    #10
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/28 23:22:11 (permalink)
    0
    I have now tested the simpler UART start-up code from the boot-loader in the main programme, with slightly worrying results.  The code works well at 57600 (no differences observed), but I get rubbish characters in RealTerm when running at 115200 baud, though receive and transmit functions are responding.  I then changed the baud rate in the boot-loader to 57600 just in case, but there was no change.  I will look into this later.
    This would suggest that the problem is elsewhere, so I will try the boot-loader code as a programme in normal memory space.
    No real insight, I'm afraid, at this stage.  the problem must be somewhere else, but it is not clear where.
    #11
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/29 00:44:27 (permalink)
    0
    I think that I have made progress, though I am not quite sure if I am convinced just yet.
    Firstly, the problem at 115200 in 'main' was more due to RealTerm getting out of sync than a problem with the PIC.
    I transferred the boot-loader code (simplified) to reside in main memory, and had similar problems with writing to the device.  I then ignored the template setup for the PIC itself (#params), and inserted the one that I normally use.  This seemed to solve the problem.
    Line by line comparison (which I had done before, but you often read what you expect to read) revealed that the template was set to POSCMOD = HS, whereas I use XT mode...
    I am struggling a bit to explain why this caused the observed effect, but it now seems to work as expected.  I will now, late and over-budget, return to completing the actual boot-loadable version of the software...
    Thank you for your advice and support.  Apologies for raising this issue; my concern was my lack of familiarity with the PPS functionality.
     
     
    #12
    PhilipJ
    Junior Member
    • Total Posts : 80
    • Reward points : 0
    • Joined: 2010/07/06 06:14:40
    • Location: 0
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/29 01:47:40 (permalink)
    0
     
    I don't know if this has already been asked/checked, but have you setup the Peripheral Pin Select module?
     
    You mention your success with a PIC32MX7xx but that device never had the Pin Select module, which maps the internal peripheral device's inputs and outputs to selected IO pins.
     
    Without setting that correctly your UART will work but nothing will appear on or be read from the pins. I can't offer you any code suggestions as I always use the PLIB functions or Harmony and you appear to be writing directly to the CPU registers, but I'm sure the details are there in section 11.3 of the data sheet (DS60001168J).
     
    I hope this helps
    PhilipJ
     
    #13
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/29 02:14:47 (permalink)
    3 (1)
    Dear PhilipJ,
    Thank you for your comment.  Yes, I believe that I have initialised the PPS correctly, and it seems to work on my main program.  I also changed back to the PLIB libraries for safety, but I think that the direct write to the bits was probably OK.
    Having said that, I still cannot get the PIC32UBL.exe PC program to talk to my boot-loader, so I have not really made progress, despite my last post...
    My test reads and writes work well when communicating with an instance of RealTerm on the host PC, but not with the all-important PIC32UBL application.  I'm just re-reading AN1388 in case I have missed anything.  this is really annoying, as I had no real problems with this serial boot-loader a couple of years ago when working with a PIC32MX795 device...
    I'm obviously missing something!  Probably in the memory map, but that looks OK at first pass.
    Best wishes
     
    #14
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/29 03:57:24 (permalink)
    0
    I have checked and my earlier work on the PIC32MX7XX, which still works fine.  I had also not really thought through the 3k limitation of the boot ROM on the PIC32MX1XX family, and I wonder if this is the problem.  A minimalist version still seems to take 3968 (0xF1C), according to the program statistics window, which would appear to be too big (max permitted is 3056 / 0xBF0).  Perhaps this is the root of all evil!  Code seems to appear at 1D00 1000, which I need to check against the mapping.
    I will need to figure out how to split into program memory... Thankfully I have space available.
    #15
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/29 04:18:29 (permalink)
    0
    It looks as if this memory mapping is handled automatically by the 'environment'.    I am not quite sure why the code starts at address 1D001000 rather than 1D000000, but it is there and seems to run.  Another red herring...  I am totally out of my comfort zone on this one!
    If anyone has any advice, I would be very grateful.
     
    PIC32UBL.exe complains that it cannot set up the comms channel, which is not very helpful.
     
    #16
    rodims
    Super Member
    • Total Posts : 1478
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/29 05:00:05 (permalink)
    0
    To sum up, what I understand is that you now successfully can communicate with e.g. Realterm at e.g. 115200 baud in both directions (TX,RX) from your bootloader on PIC32MX170F256B 
     
    But PIC32UB.exe cannot open the (or what does 'set up' mean?) the communication channel, though the PIC initialization and UART settings are identical in your bootloader compared to the Realterm test?
     
    VJM345I have checked and my earlier work on the PIC32MX7XX, which still works fine

     
    What is the physical connection between your current PIC and the PC ? 
    RS232 ?
    USB to serial converter ?
     
    And is the "PIC32UB.exe file and port settings"  for the working older PIC32MX7XX identical to the current system where PIC32UB.exe " cannot setup the comms channel" ?
    (same Windows PC, same physical connection, only different PIC ? )
     
    You first need to check what "cannot setup the comms channel" really means. 
    #17
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/29 05:45:28 (permalink)
    0
    Dear rodims,
    Thank you for your continued interest.  I will try to answer each question in turn, as I am really struggling to make sense of the current position.
     
    To sum up, what I understand is that you now successfully can communicate with e.g. Realterm at e.g. 115200 baud in both directions (TX,RX) from your bootloader on PIC32MX170F256B : Yes.
     
    But PIC32UB.exe cannot open the (or what does 'set up' mean?) the communication channel, though the PIC initialization and UART settings are identical in your bootloader compared to the Realterm test? : I was not very clear here.  PIC32UB.exe opens normally, but will not connect to the unit.  It indicates 'please reset device and invoke bootloader', and times out with 'no response from the device. Operation failed'.  This is exactly the same response as if there is no device connected to the serial port.  The settings are the same.
     
    What is the physical connection between your current PIC and the PC ? RS232 ? USB to serial converter ? : I use a docking station for my laptop (W10), so I have an RS-232 serial port available.  I used this connection for both the new MX170 unit and the older MX795 board (and physically identical connection for RealTerm).
     
    And is the "PIC32UB.exe file and port settings"  for the working older PIC32MX7XX identical to the current system where PIC32UB.exe " cannot setup the comms channel" ?
    (same Windows PC, same physical connection, only different PIC ? ) :  It is the same instance of the PIC32UB.exe, running on the same W10 PC.  The PIC settings are slightly different as the operating clock is double for the 795 device, and there is an additional set-up pragma required for this device.
     
    Apologies if I caused confusion on the 'cannot ...channel' point - I meant that I could not connect, as noted above.
    I am running out of ideas.  I have checked the memory map, and the instructions appear to be in sensible locations in boot ROM and in program ROM, as required given the smaller boot ROM on the 170 device, but I cannot pretend to interpret them further.  I would be happy to provide code or other information if you have any ideas!
    Thanks again.
    #18
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/29 05:59:59 (permalink)
    0
    Dear rodims,
    The only additional item of information that I can provide is that I cannot get the direct bit setting to work on this device.  I have to use library functions to initialise the UART, which is not the case for the MX795 device.
    The relevant code is:

    void UartInit(UINT pbClk)
    {
        PPSUnLock;                          // Allow PIN Mapping
            PPSOutput(1, RPA0, U1TX);       // MAP UART1 Tx to PA0
            PPSInput (3, U1RX, RPA4);       // MAP UART1 Rx to PA4
        PPSLock;                  // Prevent Accidental Mapping   
        UARTConfigure ( UART1, (UART_ENABLE_PINS_TX_RX_ONLY) );
        UARTSetDataRate(UART1, (SYS_FREQ / 2), DEFAULT_BAUDRATE);
        UARTSetLineControl ( UART1, (UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1) );
        UARTEnable ( UART1, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX) );
        //U1BRG = ((pbClk/(16*DEFAULT_BAUDRATE))-1); // calculate actual BAUD generate value.
        //U1MODE = UART_EN;
        //U1STA = (UART_RX_ENABLE | UART_TX_ENABLE); 
    }

    When I swap the last three lines for the previous 4, I get funny characters on the RealTerm screen.  This makes me suspect the oscillator or its settings, but the board layout looks reasonable and I have had no other problems.
    Does this provide you with an additional clue?
     
    #19
    VJM
    Super Member
    • Total Posts : 196
    • Reward points : 0
    • Joined: 2013/04/16 10:09:35
    • Location: 0
    • Status: offline
    Re: Problems with UART boot loader on PIC32MX170F256B 2017/06/29 06:51:37 (permalink)
    0
    To provide a bit of flesh to the last post, the direct bit setting seemed to work well up to 57600 baud, but not at 115200 baud as programmed.  pbClk is set correctly to 20MHz in all cases, and U1BRG to 20 for 57600 (could not see this for 115200 baud). 
    Looking more closely at this, the calculation :
    U1BRG = ((pbClk/(16*DEFAULT_BAUDRATE))-1); // calculate actual BAUD generate value.
    generates a value of 9, which does not work...  If this is set to ten, then the problem goes away.  Might be of broader interest - rounding problems v truncation.
    If I force the U1BRG value to 10, comms work fine.
    Another red herring...
    Still stuck!
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2019 APG vNext Commercial Version 4.5