Search code examples
cpicbootloadermicrochipmplab

How do you set config bits EZBL bootloader project?


I need to change the config bits in a EZBL bootloader project.

I'm able to compile it, with version 2.11 and MPLAB X ide 5.4

The problem is that config bits are fully wrong, and if i modify them in mplab ide they are gone to the old value after recompile. That means that config bits are set programally or set in project.

So, how do you change config bits in the project?


Solution

  • Ok after some tries i got it.

    In ezbl the bits are changed using EZBL_SET_CONF inside the right file of folder "Hardware initializers" used for your device.

    For example for my device PIC24J256GB406 the file is pic24j256gb410_explorer_16.c

    inside the file you can see

    *EZBL_SET_CONF(_FSEC, BWRP_OFF & BSS_OFF & BSEN_OFF & GWRP_OFF & GSS_OFF & CWRP_OFF & CSS_DIS & AIVTDIS_DISABLE)
    EZBL_SET_CONF(_FOSCSEL, FNOSC_FRC & PLLMODE_PLL96DIV2 & IESO_OFF)
    EZBL_SET_CONF(_FOSC, POSCMOD_XT & OSCIOFCN_ON & SOSCSEL_ON & PLLSS_PLL_PRI & IOL1WAY_OFF & FCKSM_CSECME)
    EZBL_SET_CONF(_FWDT, WDTPS_PS1024 & FWPSA_PR32 & FWDTEN_SWON & WINDIS_OFF & WDTWIN_PS75_0 & WDTCMX_LPRC & WDTCLK_LPRC)
    EZBL_SET_CONF(_FPOR, BOREN_ON & LPCFG_ON)
    EZBL_SET_CONF(_FICD, ICS_PGx2 & JTAGEN_OFF & BTSWP_ON)
    EZBL_SET_CONF(_FDS, DSWDTPS_DSWDTPS0D & DSWDTOSC_LPRC & DSBOREN_ON & DSWDTEN_ON)
    EZBL_SET_CONF(_FDEVOPT1, ALTCMPI_DISABLE & TMPRPIN_OFF & TMPRWIPE_OFF & ALTVREF_ALTVREFDIS)
    

    all the different config registers and flags to change them.

    You cant use the pragma way commented in other answer because it is not exported to the .s file that you will need to your projects that use bootloaders.