1. 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.
    Dismiss Notice

Bizarre MPLab 8.92 Problem (SOLVED)

Discussion in 'Microcontrollers' started by jpanhalt, Aug 14, 2017.

  1. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    5,888
    Likes:
    501
    Location:
    Cleveland, OH, USA
    ONLINE
    Working on a program that was working prior to an MPLab fail. Now program will not build and lots of #113 (Symbol no previously defined) and #126 (Argument out of range ) errors.
    Language: MPASM
    Assembler: MPLab 8.92
    MCU: PIC16F1829 @ 5V
    Programmer: ICD3

    Sequence of events:
    Project involves controlling the AS3935 lightning detector. I typically work with a single project folder. As I develop various versions of the program, they go in the same project folder and are added or removed from the project tree as needed. When changing the active/working .asm file, I go to build options and disable case sensitivity. This particular project now has about 6 versions of the assembly file.

    Each program version has the same set of macros. They include a delay macro and stack-based print macro from Mike -- K8LH. There are a couple of other macros that I wrote. The macros work in every version of this program.

    As I was doing hardware debugging of the current program MPLab stopped and gave an message that source code had changed and gave me the option of "rebuilding now." Source code hadn't changed, but I agreed to the rebuild. All hell then broke loose.

    Cannot get the program to build. There are a slew of #113 and #126 errors. All of which point to calls from the macros.

    The Watch window is a complete mess:
    upload_2017-8-15_0-2-3.png

    Those missing registers are all defined:

    Code (MPASM):

         CBLOCK 0x70     ;registers 0x70 to 0x7F accessible on from all banks
    delayhi                  ;used in DelayCy macro
    char
    char_lo
    XPos
    ;txbyte                  ;input to Put232
    count
    temp                     ;generic temp register
    Reg3
    Reg4
    Reg5
    Reg6
    Reg7                     ;AS3935 distance reg

            ENDC

         #define   SCK       PORTB,6 ;SPI clock
         #define   SDO       PORTC,7 ;MOSI
         #define   SDI       PORTB,4 ;MISO                  
         #define   CSn       LATC,6  ;!SS or chip select, pin7
         #define   Ser_out   LATC,4  ;serial output pin              only used in LCD initialization CHECK PUT232&&&&&&&&&&&
         #define   TxOut     4       ;RC4,output pin bit number
         #define   SW1       5       ;RB5  
         #define   SW2       7       ;RB7  
     
    What I have tried:
    1) Turned everything off, disconnected, exited and reopened MPLab a few times. Same result.
    2) Removed current version of program from the project tree and re-installed most recent previous version. Version has same macros . That version built fine. Reversed that process and re-installed current version -- still fails.
    3) Tried going to release mode and programmer. Still doesn't work.

    Assumption:

    MPLab acts as if it has inserted some flag or block that is preventing it from loading/reading the entire code. Is there any way to look at what it may have done and forcibly make it read the whole code?

    John
     
  2. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,011
    Likes:
    317
    Location:
    Brisbane Australia
    I've had this happen in the past and the only way I found to get everything working again was to make a new project and copy and paste the source files into it. It's like you say, it's as if a flag has been set or a path changed but I could never find it.

    Mike.
     
    • Like Like x 1
  3. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,151
    Likes:
    907
    Location:
    Rochdale UK
    ONLINE
    Agreed! The project file has become corrupt... I also have had this happen!! The last time I either deleted the MCP file or the MCW file and it winged but rebuilt a new one.... I think it was the latter!

    Before you try... Rebuild the project rather than build... Rebuilding renews the project...
     
    • Like Like x 1
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    5,888
    Likes:
    501
    Location:
    Cleveland, OH, USA
    ONLINE

    Thanks, Ian.

    By the time I went to bed, I had some plans, but as I get up at 0400 local, they had to wait. I will try your suggestion of deleting a file first. My idea was to install one of the programs that works. Then copy past the bad code to a text file (Notebook), save, and then re-open it in a fresh window in MPLab and save as .asm. If those fail, I will try copying the body of the code to a working head (everything above "start") or visa versa.

    Will let you know what happens.

    John
     
  6. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    5,888
    Likes:
    501
    Location:
    Cleveland, OH, USA
    ONLINE
    Success

    Deleting MPLab files and a lot of other failed tries didn't work. Of course, the errors were a bit too cryptic to help, and I am too damn dyslexic to recognize correctly every character in a statement.

    After whittling the "failed" program down to its bare essentials, I noticed something in the delay subroutine:
    upload_2017-8-15_7-21-52.png

    I don't have a clue how it got there, but that was the issue. I did not consciously mess with any of my regular routines. No more two pages of errors. Original compiles just fine . Conclusion: "+" is not always better.:)

    When we installed new software in our labs, IT could do a character by character comparison of results (many thousands) to find errors. Is there anyway to do that within MPLab or in a text file using Office or other software?

    EDIT: As much as I hate Word, it does have a document compare, and it was able to find the error in a test:

    upload_2017-8-15_12-42-46.png

    Didn't even have to change the extension from .asm to a more conventional text extension.

    John
     
    Last edited: Aug 15, 2017
    • Like Like x 2
  7. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,637
    Likes:
    109
    Location:
    Michigan, USA
    Ouch! Man, my cat has done that to me before (added a character to a source file). Unfortunately, that extra character you finally found doesn't really look out-of-place in that rather cryptic macro code (sorry)...

    Happy to hear you found it and got it working again.

    Cheerful regards, Mike
     

Share This Page