Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] MPLAB X infinite while loop doesn't work

Status
Not open for further replies.

Konric

Newbie level 3
Joined
Oct 24, 2015
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
47
I am trying to simulate some code in MPLAB X but am having a problem with the while loop, so I started a new project with only two instructions to execute to make sure that something else in my code wasn't causing a problem.
Here is the code:

int main(void) {

TRISA = 0xFFFF;
while (1);

return 0;
}

I set a break point at TRISA = 0xFFFF;.

For some reason when I run it the program will enter the infinite while loop and after 128 seconds it will stop at the break point that I set and say:

"Break point at line 12 in file cannot be resolved to a valid program memory address"

The only time that the infinite while loop will work as expected is if you put it as the very first instruction to execute which is utterly useless.

Is this a problem with the compiler/simulator or is there some kind of setting that I should be aware of.

I have never come across this kind of problem with the old MPLAB nor with uKeil.

Does anyone know what is going on?
 

128 seconds sounds like a watchdog timeout. It causes the reset circuits to be triggered internally and forces a jump to the reset vector so it may not be possible to determine the program counter address at the time just before the reset. If you have the watchdog enabled, try turning it off to see if it cures the problem. If it does, consider restting it inside the while() loop.

What PIC are you using that has a 16-bit TRISA register?

Brian.
 
  • Like
Reactions: Konric

    Konric

    Points: 2
    Helpful Answer Positive Rating
Thank you, you were right it was the watchdog timer causing it.

I'm simulating the dsPIC33EP512MU814 but that code was just an arbitrary instruction to see if the while loop was the cause of my problems or if it was the other instructions in my actual code.

Thanks again
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top