MPC5604B program interrupt being generated for stw

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPC5604B program interrupt being generated for stw

Jump to solution
810 Views
pradeepmc
Contributor II

Hi,

I was trying to add some assembly code in my project.
I am using the following Codewarrior 10.7 evaluation edition.
Target MCU is MPC5604B.
The following default settings are ON for the project:
c/c++ build -> settings -> PowerPC CPU -> Processor is set to ZEN (I cant find e200z0h core)
c/c++ build -> settings -> PowerPC CPU -> Compress for PowerPC VLE (zen)
c/c++ build -> settings -> PowerPC Compiler -> Processor -> Translate PPC ASM to VLE ASM (ZEN)

I have created a normal c project. And I have one assembly source file within the project.

When the below code is executed, a Program interrupt is hit (IVOR6).
Snippet of code in the source file.


# Saves context to task stack
.macro portSAVE_CONTEXT
    stw         r1,-0x98 (r1)       # store backchain    ----> code causing the interrupt
    addi      r1,r1, 0x98         # allocate stack
    stw     r0,  0x24 (r1)
    ....
.endm

.text
.align 4
vPortYield:
    portSAVE_CONTEXT

The disassembled code for the above pointed instruction is below. Though I am not quite sure how it is translated by Codewarrior.
267           portSAVE_CONTEXT
40001418:   se_stb r2,0(rsp)
4000141a:   dc.w 0xff68        -----> the actual instruction that is causing the interrupt.
4000141c:   e_lha rsp,152(rsp)
40001420:   se_stb r0,0(rsp)

I couldn't find the what the instruction "dc.w" means.
The following are the register when the interrupt was generated.

SRR0: 0x4000141a
ESR: 0x08000020  --- PIL = 1; VLEMI = 1

 Can somebody help me with the reason for the interrupt being generated?

Regards,

Pradeep M C

Labels (1)
Tags (2)
1 Solution
637 Views
pradeepmc
Contributor II

Hello Martin,

I was able to resolve the issue.
The issue was related to the below setting and where the code was placed in the elf binary.

  1. I set following  to ON for the project:
    c/c++ build -> settings -> PowerPC CPU -> Compress for PowerPC VLE (zen)

     2. Then did a clean of the project. (may be i missed this step earlier, before raising the query in the forum)

     3. Changed the instructions to vle.

macro portSAVE_CONTEXT
      e_stw     r1,-0x98 (r1)        /* store backchain     */
    e_add16i  r1,r1, 0x98       /* allocate stack     */
    e_stw      r0,  0x24 (r1)    /* Store r0 working register  */

Now the disassembler has the same vle instructions written by me and no interrupts were generated.

What exactly happened with this change?
The above code was placed in .text_vle section now in the working case.
In the issue case, it was placed in .text section and probably codewarrior converted my instructions to non-vle.
May be this could have been the reason for the dc.w instructions and correspondingly a program interrupt on it's execution.

Below is the snippet of the linker command file of my project for reference:

GROUP : {
        /* Section used for initialization code: __ppc_eabi_init.c,
        MPC56xx_HWInit.c, MPC56xx_init_*.c and the entry point (__startup).
        */
        .init : {}
        .init_vle (VLECODE) : {
            *(.init)
            *(.init_vle)
        }

        /* ISR handlers code. */
        .__exception_handlers  (VLECODE) : {}

        .text (TEXT) ALIGN(0x10) : {}
        .text_vle (VLECODE) ALIGN(0x10): {
            *(.text)                ------------------> code was placed here in issue case.
            *(.text_vle)            ------------------> code was placed here in working case.
        }

Regards,

Pradeep M C

View solution in original post

0 Kudos
2 Replies
637 Views
martin_kovar
NXP Employee
NXP Employee

Hello,

from your description, it is difficult to say, what should be the source of the issue. Could you please share some projects, which demonstrates the problem?

Regards,

Martin

638 Views
pradeepmc
Contributor II

Hello Martin,

I was able to resolve the issue.
The issue was related to the below setting and where the code was placed in the elf binary.

  1. I set following  to ON for the project:
    c/c++ build -> settings -> PowerPC CPU -> Compress for PowerPC VLE (zen)

     2. Then did a clean of the project. (may be i missed this step earlier, before raising the query in the forum)

     3. Changed the instructions to vle.

macro portSAVE_CONTEXT
      e_stw     r1,-0x98 (r1)        /* store backchain     */
    e_add16i  r1,r1, 0x98       /* allocate stack     */
    e_stw      r0,  0x24 (r1)    /* Store r0 working register  */

Now the disassembler has the same vle instructions written by me and no interrupts were generated.

What exactly happened with this change?
The above code was placed in .text_vle section now in the working case.
In the issue case, it was placed in .text section and probably codewarrior converted my instructions to non-vle.
May be this could have been the reason for the dc.w instructions and correspondingly a program interrupt on it's execution.

Below is the snippet of the linker command file of my project for reference:

GROUP : {
        /* Section used for initialization code: __ppc_eabi_init.c,
        MPC56xx_HWInit.c, MPC56xx_init_*.c and the entry point (__startup).
        */
        .init : {}
        .init_vle (VLECODE) : {
            *(.init)
            *(.init_vle)
        }

        /* ISR handlers code. */
        .__exception_handlers  (VLECODE) : {}

        .text (TEXT) ALIGN(0x10) : {}
        .text_vle (VLECODE) ALIGN(0x10): {
            *(.text)                ------------------> code was placed here in issue case.
            *(.text_vle)            ------------------> code was placed here in working case.
        }

Regards,

Pradeep M C

0 Kudos