Debugger won't allow breakpoint

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

Debugger won't allow breakpoint

Jump to solution
974 Views
meiermat
Contributor I

When I try to set a breakpoint at a certain section of code, the debugger replies with

 

"Breakpoint could not be set at line 26, moved to line 29."

 

This happens only at lines 26 and 27.  Any other locations are just fine, and work properly.

 

I'm using the PE USB Multilink, with an MC9S08DZ60.  I was having this problem this morning, so I updated CodeWarrior, but it still happens.

 

I copied the entire .c file into this post, and typed a red note after each of the two lines that are giving me trouble.  I know some of the code might look a little redundant; I've pared it down quite a bit to try and isolate a problem detecting phase currents, and then I ran into the present issue.  Any help would be much appreciated.

 

Thanks,

 

Matt


#include "derivative.h"
#include "timers.h"

unsigned int pwmCounter;
unsigned int delayCounter;
unsigned int lowCount = 100;
unsigned int offCount = 5000;


interrupt 11 void tpm1OvfIsr(void)
{
if (pwmCounter < offCount)
{
  pwmCounter++;
/*  if ((ADCSC1 && 0x80) != 0)//Check to see if COCO is set
  {
   if (ADCRL >= 13)// 1.28 counts/A
   {
    PTDD &= ~0x08;//Turn off Phase A
   }
   ADCSC1 = 0x20;//Start continuous conversion on Phase A
  }*/
}
if (pwmCounter == lowCount)
{
  PTDD &= ~0x0C;//Turn off D2, D3 (Phases A, B)  THIS IS LINE 26
  ADCSC1 = 0x00;//Turn off ADC          ...AND THIS IS LINE 27
}
if (pwmCounter == offCount)
{
  pwmCounter++;
  PTDD &= ~0x0C;//Turn off D2, D3 (Phases A, B)
  ADCSC1 = 0x00;//Turn off ADC
}
TPM1SC &= ~0x80;//Clear OVF Flag
}

interrupt 14 void tpm2OvfIsr(void)
{
if (delayCounter < 5000)
{
  delayCounter++;
}
TPM2SC &= ~0x80;//Clear OVF Flag
}

void initTimers(void)
{
//Timer 1 - 1kHz
pwmCounter = 0;

TPM1MODH = 0x06;//ModH and ModL set the timer period
TPM1MODL = 0x40;//An 8MHz clock divided by $0640 gives a 5kHz frequency

TPM2MODH = 0x1F;//ModH and ModL set the timer period
TPM2MODL = 0x40;//An 8MHz clock divided by $1F40 gives a 1kHz frequency
 
/* TPM1C0SC = 0x28;//Set MSnB and ELSnB, for edge-aligned, high-true PWM operation
TPM1C0VH = 0x00;//Sets the duty cycle for Channel 0
TPM1C0VL = 0x00;//0%

TPM1C1SC = 0x28;//Same for channel 1
TPM1C1VH = 0x00;
TPM1C1VL = 0x00;*/

TPM1SC = 0x48;//Set TOIE and CLKSA, for interrupts enabled and bus clock source
TPM2SC = 0x48;//Set TOIE and CLKSA, for interrupts enabled and bus clock source
}

Labels (1)
0 Kudos
Reply
1 Solution
813 Views
pgo
Senior Contributor V

Hi Matt,

The ability to place breakpoints can be affected by the optimisation level applied.  The HCS08 Compiler will often factor common portions of code which can make placing a breakpoint impossible.  In your case it may have factored lines  26/27 and lines 32/33 so cannot set an breakpoint at those lines.

Checking the optimisation level and reducing it may be worth trying.,

bye

View solution in original post

0 Kudos
Reply
3 Replies
814 Views
pgo
Senior Contributor V

Hi Matt,

The ability to place breakpoints can be affected by the optimisation level applied.  The HCS08 Compiler will often factor common portions of code which can make placing a breakpoint impossible.  In your case it may have factored lines  26/27 and lines 32/33 so cannot set an breakpoint at those lines.

Checking the optimisation level and reducing it may be worth trying.,

bye

0 Kudos
Reply
813 Views
meiermat
Contributor I

Right!  I always forget about the compiler when I'm writing in C.  So stupid.

Thanks a million.

0 Kudos
Reply
813 Views
juhaaaltonen
Contributor I

Without knowing anything about your compiler, have you tried removing the //-comments?

Maybe your compiler doesn't like mixing /* -comments and //-comments...

The error you are getting is usually given in situations were you are trying to put a breakpoint in non-reachable code.

Instead the breakpoint is set in the next "acrtive" codeline. The unreachable code is typically:

1) Commented out

2) #if-ed out

3) Outside any function (due to braces mismatch

0 Kudos
Reply