I got some questions about the breakpoints in debug mode. Below is a simple program to explain.
Putting breakpoints before the first 3 lines in main just works as expected, but aren't declarations like counter, and counter_limit able to stop the program? Is there a reason?
I tried putting a breakpoint before the LED toggle point PTD->PTOR = 1<<0; but it just gets ignored..?
And if I put it next line when counter is set to 0 again the program stops at this point every single cycle of the for loop (even if the if-request isn't true), and that confuses me most..
I hope someone can enlighten me
volatile int exit_code = 0;
PCC->PCCn[PCC_PORTD_INDEX] = PCC_PCCn_CGC_MASK; //enabling clock for PORT D
PORTD->PCR = PORT_PCR_MUX(1); //set pin as GPIO
PTD->PDDR = 1<<0; // pin 0 is configured as output
int counter = 0;
int counter_limit = 100000;
if(counter > counter_limit)
PTD->PTOR = 1<<0;
counter = 0;
if(exit_code != 0)
This may be caused by the different locations of variables in memory, and the debugger cannot access this storage space.
The shaded part on the left is where breakpoints can be placed.(I use KEIL to port you code.)
Here is you code,
Turn it into a global variable
That's all I know, and I hope this answer is useful to you.