Debugger Issues

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

Debugger Issues

1,442 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by richas on Tue May 14 13:28:14 MST 2013
I was having issues with the debugger (LPC1768, Red Probe+) where I had to always start the debugger twice, the first try would produce a "flash init" error.

I FINALLY traced the issue to a variable in the timer0 ISR.  The variable is simply used as a flag to toggle a "heartbeat" LED.

The variable was declared as static int inside the ISR.  I moved the variable to the top of the module and declared it as volatile and the issue is gone, the debugger starts without errors each time.

Ideas?

Rich
0 Kudos
Reply
5 Replies

1,434 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Tue May 14 15:21:05 MST 2013

Quote: richas
I am not sure how the variable ended up being declared as static.  Nor am I sure that it is improper to declare a variable as static in an ISR when it is not used outside the ISR (Just like any other function).  If it does not work in an ISR I would be interested in knowing why.

(And why it breaks the debugger would also be interesting.....)

Rich



There's nothing peculiar about declaring a static variable in an ISR. If an initial value is supplied, the startup code will initialize it (along with other initial data) provided it locates within a data section the startup code knows about. The flash driver itself locates in RAM, probably in the same space as your static variable. It's unclear why this would cause a problem for the flash driver initialization since interrupts get disabled at the start of a debug session, and active and pending interrupts are cleared. You'll need to post your code and/or a project which can reproduce the problem.

Regards,

CodeRedSupport
0 Kudos
Reply

1,434 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue May 14 15:15:45 MST 2013

Quote: richas
Nor am I sure that it is improper to declare a variable as static in an ISR when it is not used outside the ISR (Just like any other function).  If it does not work in an ISR I would be interested in knowing why.



Static locals in ISR are working as usual and therefore not stacked. Your map file should show them in RAM (BSS section).
Also your debugger should show you in Disassembly ('Instruction stepping mode') what's going on there.
0 Kudos
Reply

1,434 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Tue May 14 14:42:32 MST 2013
Why don't you post a project that exhibits the problem. Maybe we can the see what you are doing.
0 Kudos
Reply

1,434 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by richas on Tue May 14 14:08:19 MST 2013

Quote: R2D2
What you are describing sounds like a 'wrong' usage of 'static' qualifier.

See: http://en.wikibooks.org/wiki/C_Programming/Variables#static

Perhaps you can post the code to investigate that :)



I am not sure how the variable ended up being declared as static.  Nor am I sure that it is improper to declare a variable as static in an ISR when it is not used outside the ISR (Just like any other function).  If it does not work in an ISR I would be interested in knowing why.

(And why it breaks the debugger would also be interesting.....)

Rich
0 Kudos
Reply

1,434 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue May 14 13:58:30 MST 2013
What you are describing sounds like a 'wrong' usage of 'static' qualifier.

See: http://en.wikibooks.org/wiki/C_Programming/Variables#static

Perhaps you can post the code to investigate that :)
0 Kudos
Reply