• AVR Freaks

Hot!Change EZBL ex_boot_uart clock settings

Author
SergioP
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2018/09/10 05:34:19
  • Location: 0
  • Status: offline
2020/05/20 05:48:48 (permalink)
0

Change EZBL ex_boot_uart clock settings

Hello,
Has anyone successfully tried to change EZBL ex_boot_uart project settings to run on a 20 MHz external clock? What changes should be done to this project?
This is my situation:
When I program my dsPIC33FJ256GP710A with my project and integrated bootloader I can upload trough UART a new application at 460800 baudrate. If the upload fails the micro falls back to the bootloader and im not able to upload new firmware anymore. When I program only the bootloader I can neither upload firmware.
This leads me to think that there is a configuration in my project that is missing or different from the bootloader, but Im not able to configure ex_boot_uart in the same way.
This is the clock configuration in my project:
    // Configure PLL prescaler, PLL postscaler, PLL divisor
    PLLFBD = 30; // M = 32 (PLLFBD=30), PLL Feedback Divisor bits (also denoted as M, PLL multiplier)
    CLKDIVbits.PLLPOST = 0; // N2 = 2
    CLKDIVbits.PLLPRE = 2; // N1 = 4
    CLKDIVbits.DOZE = 0; //Divided by 1
        
    // Initiate Clock Switch to Primary Oscillator with PLL (NOSC = 0b011)
    __builtin_write_OSCCONH(0x03);
    __builtin_write_OSCCONL(0x01);
    while (OSCCONbits.COSC != 0b011){}; // Wait for Clock switch to occur
    while(OSCCONbits.LOCK != 1) {}; // Wait for PLL to lock

 
I have tried multiple configurations in ex_boot_uart project without any results. I have tested different Device COnfiguration Words and commented and adapted the section in the hardware initializer where it sets the clock configuration.
Does anyone know how to make te appropriate changes?
 
Thanks in advance. Any help will be appreciated.
#1

6 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 3942
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Change EZBL ex_boot_uart clock settings 2020/05/20 06:02:53 (permalink)
    0
    If you can upload WITH the application but not without, the boot loader might lack a proper baud rate initialization at all. Or something is amiss.
    I'd suggest starting with "convincing" the boot loader (without application) to continuously transmit "something" on the UART. This way you can check the actual baud rate.
    Then . . . tweak and check . . .

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    SergioP
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2018/09/10 05:34:19
    • Location: 0
    • Status: offline
    Re: Change EZBL ex_boot_uart clock settings 2020/05/20 07:12:47 (permalink)
    0
    du00000001, thankyou, you are right, it seems more a com problem than a clock problem. I can see a 460800 baudrate message going out of UART but pins U2RTS and U2CTS are not working properly. As I send this message to a RS-485 converter, this signal is mandatory in my board.
    I've done a couple of modifications in ex_boot_uart hardware initializer but still no success. At least I can see the message at the proper baudrate and the proper repetition rate (sync with heartbeat LED). I will keep trying to find the correct configuration (Supposing that EZBL allows this)
    #3
    Severino
    Starting Member
    • Total Posts : 36
    • Reward points : 0
    • Joined: 2014/04/30 01:50:28
    • Location: 0
    • Status: offline
    Re: Change EZBL ex_boot_uart clock settings 2020/05/20 07:15:18 (permalink)
    0
    Do you disable EZBL in your application or is it running in the background?
     
    To be sure that EZBL is running at the correct frequency, you can theck if the LED blinks at 8 Hz (if your board has such an LED, otherwise it could be helpful adding one for debugging).
    BTW: what board is your application running on?
    #4
    du00000001
    Just Some Member
    • Total Posts : 3942
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Change EZBL ex_boot_uart clock settings 2020/05/20 07:33:40 (permalink)
    4 (1)
    SergioP
    du00000001, thankyou, you are right, it seems more a com problem than a clock problem. I can see a 460800 baudrate message going out of UART but pins U2RTS and U2CTS are not working properly. As I send this message to a RS-485 converter, this signal is mandatory in my board.
    I've done a couple of modifications in ex_boot_uart hardware initializer but still no success. At least I can see the message at the proper baudrate and the proper repetition rate (sync with heartbeat LED). I will keep trying to find the correct configuration (Supposing that EZBL allows this)



    As you can already see the correct baudrate going out, why not check the same following the RS-485 converter ?

    If anything transmitted is truncated (the most common error with RTS/CTS hardware flow control done in software), this will show up clearly when plotting UART TX and RS-485 (D+) one above the other.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #5
    SergioP
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2018/09/10 05:34:19
    • Location: 0
    • Status: offline
    Re: Change EZBL ex_boot_uart clock settings 2020/05/21 01:09:17 (permalink)
    0
    du00000001, it seems that EZBl does not initialize RTS/CTS properly by default. I have added the following code after UART configuration in ex_boot_uart project:
     
        EZBL_COMBootIF = UART_Reset(2, FCY, EZBL_COMBaud, 1); 

        //////////////////////////////////////////////////////////////////////////// CUSTOM UART CONF
        U2MODEbits.RTSMD = 1; // Bit11 Simplex Mode
     U2MODEbits.UEN = 2; // Bits8,9 UxTX, UxRX, UxCTS and UxRTS pins are enabled and used
        //////////////////////////////////////////////////////////////////////////// CUSTOM UART CONF

     
    Also, I had enabled the following code in ex_boot_uart main to improve performance, but was making file transfer to fail (don't know why):
    // Uncomment for superior performance (with baud rates up to 761kbps). Buffer
    // default size is 96 bytes in ezbl_lib, which conserves static RAM, but reduces
    // sustained throughput. Any size >= 64 bytes can support bootloading.
    //unsigned char UART2_RxFifoBuffer[256] __attribute__((noload, section(".bss.UART2_RxFifoBuffer")));

     
    With this two modifications EZBL is working properly now.
     
    Severino, the board that I'm using is custom, not a demo or eval. And I'm giving the control of all interrupts to the application and only giving back the control of the UART2 to the bootloader when a firmware update is intended.
     
    Thank you for your help.
     
    #6
    du00000001
    Just Some Member
    • Total Posts : 3942
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Change EZBL ex_boot_uart clock settings 2020/05/21 04:07:38 (permalink)
    0

    ... does not initialize RTS/CTS properly by default. ...

     
    AFAIK, EZBL can do without hardware flow control. Thus I assume it's not supported within EZBL.
     
    Nice to see that your controller has gotten hardware support for the hardware flow control: software solutions have some tendency to reset RTS too early, maiming/cutting off the last byte transmitted.
     

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #7
    Jump to:
    © 2020 APG vNext Commercial Version 4.5