M0 application only runs in debug

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by pcalton on Wed Mar 06 14:25:17 MST 2013
As in the Dual Core example, I have an cortex-M0 application that is converted to an array of bytes (LR0) in a C file (CM0_Image.c) that is used by the cortex-M4 application as below:

  Load Cortex M0 Application Image
void Load_CM0_Image (uint32_t DestAddr, const uint8_t *Image, uint32_t Sz)
  uint32_t i;
  uint8_t *dp = (uint8_t *)DestAddr;

  /* Copy application image */
  for (i = 0; i < Sz; i++)
    dp = Image;
  /* Set shadow pointer to beginning of the CM0 application */

void Start_CM0_Application(void)
// Stop CM0 core
LPC_RGU->RESET_CTRL1 = (1 << 24);

// Copy application from Flash to Ram
Load_CM0_Image (0x10080000, LR0, sizeof (LR0));

// Start CM0 core

The Cortex-M4 application configures the clocks and pin configuration and then calls Start_CM0_Application

When not debugging or when debugging the Cortex-M4 application the Cortex-M0 application does not appear to be executing. However, if I switch to the CM0 project and debug the cortex-M0 then everything works fine.

I am debugging the cortex-M0 using Keil and a ULINK2 using the following debug script

FUNC void Setup (void) {
SP = _RDWORD(0x00000000);                          // Setup Stack Pointer
PC = _RDWORD(0x00000004);                          // Setup Program Counter
XPSR = 0x01000000;                                 // Set Thumb bit

_WDWORD(0x400C0008, 0x00000000);                   // Disable RIT_WDT
_WDWORD(0xE000E180, 0x00000800);                   // Disable RIT_WDT_IRQHandler
_WDWORD(0xE000ED0C, 0x05FA0003);                   // VECTRESET & VECTCLRACTIVE

LOAD %L INCREMENTAL                                  // Download

Setup();                                             // Setup for Running

g, main

Can anyone please explain what I might be doing wrong that prevents the cortex-M0 from executing normally?