When running the code after the download, it never reaches the main function. FLASH programming doesn’t report any verify error.
Simple manual Mass erase via Hardware / FLASH / Mass Erase before debug download may solve the problem already.
Most probably the application remains in the BAM program because specific “startup” parameters were not programmed properly in the internal FLASH or left in the BAM area from an old (different) application. After the reset, the CPU starts executing a so called BAM (Boot Assist Module) program.
The BAM searches the internal FLASH memory for a valid reset configuration halfword (RCHW). A valid RCHW is a 16-bit value that contains a fixed 8-bit boot identifier and some configuration bits, which define location of boot code and the boot configuration options. If the BAM program does find a valid RCHW, the watchdog is enabled, the BAM program fetches the reset vector from the address of the BOOT_BLOCK_ADDRESS + 0x4, and branches to the reset boot vector. Check if valid RCHW and valid reset vector are set in user application and programmed through the debug download. Refer to CPU reference manual for more details on BAM.
Sorry this article didn't answer your question, we'd love to hear how we can improve it.
Note: This form won't submit a case. We'll just use it to make this article better.