I notice MCC ( Mplab Code Configurator ) handles this processor and has a boot loader.
Is there some reason you are not using it ?
If you were using the MCC version the reset happens here and this would be the place to add your delay.
I presume your system also has a reset command sent to the bootloader.
Thanks for the advice, but actually I wrote my own GUI for my system with the part to update the firmware (I recreated the flashing tool ezbl_comm in Labview following its comunication protocol) so I hanven't time now to change the bootloader and recreate the application. But in the future, for my new applications, I'll keep in mind your advice. Thanks.
In ex_boot_uart, main.c I see this code
The formatting sucks as it is a copy paste from the source.
It seems "EZBL_StartAppIfPresent()" actually starts the code
Does your code look like this ????
if(now - appLaunchTimer > EZBL_bootCtx.timeout)
// If auto-baud is used, automatically reset the UART back to
// auto-baud mode while idle for longer than the timeout.
if((EZBL_COMBaud <= 0) && (EZBL_COM_RX == 0))
EZBL_FIFOSetBaud(EZBL_COMBootIF, EZBL_COMBaud); // This will set EZBL_COMBootIF->activity.other,
//so appLaunchTimer will also be reset on next loop iteration
// Optionally turn off all Bootloader ISRs and forward the
// interrupts to the Application so we become a passive classic
// NOTE: You are giving up useful timing and communications APIs
// if you do this. Also, the automatic bootloader wakeup upon
// .bl2 file presentation won't work. To minimize flash, the
// App can just reuse the bootloader APIs as is, keeping the
// NOW Timer interrupt and communications ISRs active in the
// background (which have minimal run-time execution cost).
//EZBL_RAMSet((void*)&IEC0, 0x00, (unsigned int)&IPC0 - (unsigned int)&IEC0); // Clear every bit in all IECx Interrupt Enable registers
//EZBL_ForwardAllIntToApp(); // Forward all Interrupts to the Application
//NOW_EndAllTasks(); // Terminates the EZBL_BootloaderTask() from executing via background NOW ISR and when a NOW_32() or NOW_64() call is made which indirectly needs the timer ISR to execute and perform a carry propagation.
EZBL_StartAppIfPresent(); // Sets EZBL_appIsRunning = 0xFFFF and temporarily disables IPL6 and lower interrupts before launching Application
In this example EZBL_StartAppIfPresent() is a function that runs my application but when the bootloader is already started. My question is different:
When I flash my new firmware to my device, after I sent all the firmware's packets, the bootloader tell me that the whole process is terminated successfully with the status code 0x0000 and 0x0001, indicating the final disposition of the firmware update (Phase 4 in the EZBL Communication Protocol pdf). After about 300us of this response, the CPU restarts.
I want know if is possible delay that time (300us) between the final status code response (0x0000 0x0001) from bootloader anche the CPU restart.