FridgeFreezer

What's going on here then?

Discussion created by FridgeFreezer on Apr 12, 2010
Latest reply on Apr 21, 2010 by Piotr Mazur

I am gradually building up a project for MCF52259 in CodeWarrior7.2, I have a couple of interrupts set up, DMA timers running (only as pin-toggling outputs) and was working on the PWM timers when I hit a weird problem:

 

In the main() loop, if I implement a very basic for() loop using a locally declared int, the program crashes:

 

void main()

{

uint32 i = 0;

 

    while(1)

    {

       for(i = 0; i < 100; i++)

      {

            LED_TOGGLE;

      }

    }

}

 

If I do the same loop with an externally declared global variable, the thing works fine. If I cut the thing right down it still crashes:

 

void main()

{

uint32 i;

 

    while(1)

    {

      i++;

    }

}

 

If I replace it with a uint8 or int8 it behaves exactly the same.

 

What on earth is going on here?

Outcomes