Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

MPLAB SIM with HiTech C question

Status
Not open for further replies.

keny

New Member
I have attached a jpg that has the program code and also the mplab environment in it.

MPLAB SIM doesn't appear to be seeing the variable i, and is in a forever loop when it should eventually break out of the for loop. Secondly, in the watch window, it shows the variables as "restricted Memory" and does not see the array as an array. Should I not be able to see the values in the subroutine?

I'm kind of baffled about this and want to get on with debugging my program but it doesn't help when I can't see the variables within a subroutine... The other weird thing about it is that I once was able to see these variables and now cannot, and I don't think I did anything to change it.

This is just an example of my problem, not really the program I am working on...
 

Attachments

  • weird.jpg
    weird.jpg
    259.6 KB · Views: 449
HiTech programs start with an include to setup the processor and config for the chip.. etc.
Code:
  #include <pic.h>  
  __CONFIG(INTIO & UNPROTECT & BOREN & WDTDIS & PWRTEN);

I typed in your code as it was. Most sane people would have provided code that could have been cut and pasted.

I ran it in the simulator with no problems. The variable "i" looked just fine in the LOCALs window while I was in its function. Scope is important here. No loop problems.
 
Last edited:
Wow man, I guess I was all pumped up for halloween and doing insane things just runs in my blood. Lol sorry I put you through that!
here's the code

Code:
  #include <htc.h>  

__CONFIG(1, IESODIS & FCMEN & RCCLKO);
__CONFIG(2, BORDIS & PWRTEN & WDTDIS);
__CONFIG(3, MCLREN);
__CONFIG(4, XINSTDIS & STVRDIS & LVPDIS & DEBUGDIS); 

unsigned char somearray[8]; // declare an array

void getArray(unsigned char *somearray){

    //    populate the array somehow
    
    int i = 0;
    for (i = 0; i < 8; i++)
    {
        somearray[i] = 1;
    }

    return;

}





void main(void){


getArray(somearray);       
        
}


ok and here is a new screen grab with the locals window adding the configuration word and htc.h. I am still getting the problem in the watch window AND the locals window...
 

Attachments

  • weird2.jpg
    weird2.jpg
    388.6 KB · Views: 266
Last edited:
In HiTech C the local variables are preceded by the function name. So you should be looking at getArray_i.

Mike.
 
3v0, on thinking about your response, if it is working for you, then surely something must be wrong with the mplab's configuration.

I'm currently using a pic18lf13k50, I have had the same issue on a different pic, 18f2450. I am kind of thinking this is either a config issue or a my not knowing what the heck i'm doing issue, or both. I don't quite understand the things the linker does. In there are optimization settings, and on the hitech forum someone suggested that it may be related to the compiler optimizing where it stores the code in memory. (I don't get it)

**broken link removed**

I have a second XP machine with MPlab and HTC on it as well and it has the same issue. I'm just blown because I am getting to the point in my program where I need the simulator to go further and this is like a giant roadblock to me finishing my project.
 
Last edited:
It's in the righthand drop down box of the watch window. You will have to rerun the code for it to show the correct value.

Mike.
 

Attachments

  • watch.png
    watch.png
    19.4 KB · Views: 262
I get somearray and i and that's it. but what's this GOLD'NESS that I'm seeing in your thumbnail? Whats that version??? or did you just change the background?
 

Attachments

  • weird3.jpg
    weird3.jpg
    387 KB · Views: 254
The variable somearray is your array. You should be looking for getArray_i.

The colour variation is just Photoshop converting it to png. I'm on version 8.40.

Mike.
 

Attachments

  • watch.png
    watch.png
    89.7 KB · Views: 257
could the compile line have something to do with it?

Executing: "C:\Program Files (x86)\HI-TECH Software\PICC-18\PRO\9.63\bin\picc18.exe" -oblah.cof -mblah.map --summary=default,-psect,-class,+mem,-hex --output=default,-inhx032 main.p1 --chip=18LF13K50 -P --runtime=default,+clear,+init,-keep,-download,+stackwarn,-config,+clib,-plib --opt=default,-asm,-speed,+space,-9 --warn=0 -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
 
Try starting a new project and cut and past your code into it.

Edit, I just checked and the version of HiTech C I have doesn't support that chip.

Mike.
 
Last edited:
I can duplicate the problem for the pic18lf13k50. Works fine with the 18F1320.

Someone needs to look at the generated asm.

EDIT: Mike. I find it strange that the compiler does not complain about a chip it can not generate code for.
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top