AnsweredAssumed Answered

MQX BSP Port CodeWarrior Debug Issue

Question asked by Sushanta Mohan Rakshit on May 23, 2013
Latest reply on May 26, 2013 by Martin Kojtal

Hi All,


I have a custom board with the K60n512. I ported the BSP for twrk60n512 using the BSP Porting Wizard. My custom board uses a 4 MHz external crystal as the source and use the PEE mode at 96 MHz. I have a SampleMQX project which uses this BSP and I have used the PE settings to select the 4 MHz external crystal and PEE mode at 96 MHz.


I see the following behavior when I try to debug:


Execution starts at the program entry point in boot.S. The following lines of code are stepped through:


        /* disable interrupts and clear pending flags */
        ldr r0, =0xe000e180     /* NVIC_ICER0 - Interrupt Clear-Enable Registers */
        ldr r1, =0xe000e280     /* NVIC_ICPR0 - Interrupt Clear-Pending Registers */
        ldr r2, =0xffffffff
        mov r3, #8

        cbz r3, _boot_loop_end
        str r2, [r0], #4        /* NVIC_ICERx - clear enable IRQ register */
        str r2, [r1], #4        /* NVIC_ICPRx - clear pending IRQ register */
        sub r3, r3, #1
        b _boot_loop


        /* prepare process stack pointer */
        mrs r0, MSP
        msr PSP, r0

        /* switch to proccess stack (PSP) */
        mrs r0, CONTROL
        orr r0, r0, #2
        msr CONTROL, r0
        isb #15


After line 20 in the above segment code jumps to line 3 in the following:


#if defined(__CODEWARRIOR__)
        b ASM_PREFIX(__thumb_startup)
#elif defined(TOOLCHAIN_GCC_CW)
        /* call startup from EWL library */
        b ASM_PREFIX(__thumb_startup)
#elif defined(__IAR_SYSTEMS_ICC__)  || defined (__IASMARM__)
        b ASM_PREFIX(__iar_program_start)


After this the execution jumps to startup.c inside asm void __thumb_startup(void). The _bl_init_registers fall through fine. After that the call to _bl_init_hardware takes the control to comp.c __init_hardware(void) and from there to init_hw.c and from there to CPU.c __pe_hardware_initialize(void). The following lines of code execute there:


void __pe_initialize_hardware(void)
  /*** !!! Here you can place your own code before PE initialization using property "User code before PE initialization" on the build options tab. !!! ***/

  /*** ### MK60DN512ZVMD10 "Cpu" init code ... ***/
  /*** PE initialization code after reset ***/
  /* SIM_SCGC6: RTC=1 */
  SIM_SCGC6 |= (uint32_t)0x20000000UL;                     
  if ((RTC_CR & RTC_CR_OSCE_MASK) == 0u) { /* Only if the OSCILLATOR is not already enabled */
    /* RTC_CR: SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
    RTC_CR &= (uint32_t)~0x3C00UL;                    
    /* RTC_CR: OSCE=1 */
    RTC_CR |= (uint32_t)0x0100UL;                     
    /* RTC_CR: CLKO=0 */
    RTC_CR &= (uint32_t)~0x0200UL;                    
  /* Disable the WDOG module */
  WDOG_UNLOCK = (uint16_t)0xC520U;     /* Key 1 */



At line 18 of the above segment on trying to step through it the control goes back to the first line of the boot.S segment of code given above and execution follows the same chain infinitely from there.


It will be great if somebody could point out what I am doing wrong for which the execution does not proceed further. I am using MQX 4.0.1 on CodeWarrior 10.2.


Thanks and with best regards,