PIC header files

Thread Starter

Sparky49

Joined Jul 16, 2011
833
I have it plugged into an Explorer Demo Board.

I've got the power plugged in, but still it resets, as per the screenshot above.
 

JohnInTX

Joined Jun 26, 2012
4,787
FWIW

In MPLABX:
Config bit setting and PIC header file is automated by:
Window->PIC Memory Views->Configuration Bits
In the window under Option, select what you want from the pull-down box.
When done with ALL configs, click Generate Source Code to Output
The Config Bits Source window will open with perfectly formatted code for your processor and configs. Copy and paste it into your source. Note, it also includes the proper processor header for you.

If you want to build in Absolute mode (I find it easier to manage):
Right click Project->Properties.
In Categories, click mpasm(Global Options)
Check the Build in Absolute Mode box.
That should fix Error 154.

MPLABX is different but has some nice features and for the newest chips, it will be the only (uCHIP) game in town.

Good luck.
 

Thread Starter

Sparky49

Joined Jul 16, 2011
833
Many thanks John.

I figured out my problem - I forgot to build the project. hehehe.

However, I'm still getting a similar list of errors that I had in the MPLABX:
 

Attachments

tshuck

Joined Oct 18, 2012
3,534
Many thanks John.

I figured out my problem - I forgot to build the project. hehehe.

However, I'm still getting a similar list of errors that I had in the MPLABX:
I'm pretty sure that it is because you are splitting up configuration bits into different words. Each CONFIG assigns the values to the configuration word and increments which configuration word is modified each time it sees CONFIG.

Check the datasheet for configuration word locations and its constituent bits...
 

Thread Starter

Sparky49

Joined Jul 16, 2011
833
Thanks TShuck.

To be honest, I'm struggling to understand what you mean. This is totally down to my lack of knowledge.

I've tried looking through the datasheet, but I cannot figure any meaningful result.

Would it be possible to have an example of what it should be? I've tried your earlier example and Max's, but the problem remains.

Thanks again for your patience,

Sparky.
 

MaxHeadRoom

Joined Jul 18, 2013
28,698
You need to look at section and table 25.1 of the manual.
But you don't need all of the configurations set, only the ones you are using or affect your product.
In fact the compiled example in the MASM directory only sets the Config Osc type.
There is also templates for both Abs and rel code in the suite directory.
Comment the others out, you can always enable them a line at a time and see which affects the build.
Max.
 

tshuck

Joined Oct 18, 2012
3,534
Okay, so you have
Rich (BB code):
CONFIG  OSC     = HS
CONFIG  MCLRE   = ON
CONFIG  DEBUG   = OFF
CONFIG  LVP     = OFF
CONFIG  WDT     = OFF
What this seems to be doing is
Rich (BB code):
[CONFIG  OSC     = HS ;CONFIG1H
CONFIG  MCLRE   = ON ;CONFIG1L
CONFIG  DEBUG   = OFF ;CONFIG2H
CONFIG  LVP     = OFF ;CONFIG2L
CONFIG  WDT     = OFF ;CONFIG3H
Looking at table 25-1, page 298, what you want is something like
Rich (BB code):
[CONFIG  OSC     = HS ;CONFIG1H
CONFIG  ;CONFIG1L
CONFIG   WDT     = OFF ;CONFIG2H
CONFIG   ;CONFIG2L
CONFIG  MCLRE   = ON ;CONFIG3H
CONFIG  ();CONFIG3L
CONFIG   ;CONFIG4H
CONFIG DEBUG   = OFF, LVP     = OFF  ;CONFIG4L
You will need to fill in the blanks for the other configuration words...
 

Thread Starter

Sparky49

Joined Jul 16, 2011
833
Okay, so I tried fiddling about with the commented template, the example above, and just the single Config Osc, but I'm still getting the same error messages.

:(
 

Attachments

JohnInTX

Joined Jun 26, 2012
4,787
Okay, so I tried fiddling about with the commented template, the example above, and just the single Config Osc, but I'm still getting the same error messages.

:(
Hmm... I built your original code with MPLAB 8.63/ MPASM 5.39 and it builds with no errors after tabbing the CONFIG,#include and LIST directives over 1 column (they aren't supposed to be in column 1).

Be sure to build in ABSOLUTE mode, not linked. Project->BuildOptions->Project -> on the MPASM .. Suite tab. Also select Assemble/Compile/Link in the project directory

The 'Overwriting Address 0000.." message means that something prior to your ORG 0000 has generated some code and by resetting the PC with the ORG, you are generating code on top of that. If you have made any changes to the .inc file that generate code, that will do it. (Normally, no changes are ever made to the .inc file) To check, comment out the #include and rebuild. It will complain about not knowing where TRISD is etc. but you should not have problems with overwriting. If that's the case, your .inc file is corrupt.

Open the .lst file and see what's there. You should have no code generated until the ORG. Put a label (i.e. junk: ) just before the ORG. Its value in the leftmost col. must be 0. If it isn't, drill down to your .inc file, open it and comment out NOLIST. This will cause the .inc file to be in your .lst output file. Scan down the left hand side and make sure nothing is generating any code. I'll bet you find some.

At this point, just worry about a clean build, then you can set the CONFIG bits later.

Also, the GOTO MAIN won't hurt anything. Its a good idea get into the habit of to jumping over the interrupt vectors in any case.

You don't need the LIST P=xxxx any more. That's done by MPLAB and checked by the .inc file.

Be sure you are using the right instance of P18F8722.inc. Specifying with <file> gets the one from the program files folder - I think. You can verify the right file by putting breadcrumbs in the file:
MESSG "Building with my include file"
will emit the quoted message when the file is assembled. No message? You aren't using the file you think you are.

I've attached a clean version of the .inc file for you to try.

Post both the .asm and .inc files if you need more help.

Good luck.
 

Attachments

Last edited:

Thread Starter

Sparky49

Joined Jul 16, 2011
833
Hi, I've tried the above, but it still doesn't work.

I've attached the files as asked. :)

Sparky
 

Attachments

Last edited:

JohnInTX

Joined Jun 26, 2012
4,787
Perhaps I should mention I am on Windows 8.1.
Does this have any effect?
I don't know - read the release notes Help->Release Notes for your MPLAB version to see if any are known. Win7 had some early on.

I made a new project with the two files you posted and it builds fine - only complaining about the MESSG "Building with my include file" being in the first column.

I would do this:
Close the current project and create a new one using the Project Wizard or manually.

Paste your code and use an explicit path to the include file rather than <>.
Build in absolute mode.

In the View->Project window that shows your project files:
Make sure you have only Test3.asm under Source files
Make sure you have only P18F8722.inc under Header files
Examine the other folders there to be sure you don't have any strays. If you have two instances of Test3.asm, that would account for your problem.

Have you looked at the list file? (File->Open Test3.lst) to see what might be going on? Post it if you need to and we can take a look at it.

It works under MPLABX as well.

I'm using Win7-64Pro. Which version of MPLAB are you using?

EDIT: Search Windows 8.1 on microchip.com and it has some issues with 8.1 Don't know if any are what you are seeing.

Good luck.
 
Last edited:

Thread Starter

Sparky49

Joined Jul 16, 2011
833
Thanks John, I'll have a go over the program.

In the mean time, here's the list.

Rich (BB code):
MPASM  5.51                         TEST3.ASM   4-2-2014  22:06:33         PAGE  1


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00001 
                      00002 ;#include <P18F8722.inc>
                      00003 
                      00004 ;--------------
                      00005 ;Configuration
                      00006 
00 1F 1F F3 83 85 FF C00007         CONFIG  OSC = LP             ;LP
       0 FF E0 FF 40 
                      00008 ;---------------
                      00009 ;Main program
                      00010 
000000                00011         ORG     0x0000
000000 EF02 F000      00012         GOTO    MAIN
                      00013 
000004 0E00           00014 MAIN    MOVLW   0x00
Error[113]  : Symbol not previously defined (TRISD)
000006 6E00           00015         MOVWF   TRISD
                      00016 
000008 0E55           00017 LOOP    MOVLW   0x55
Error[113]  : Symbol not previously defined (PORTD)
00000A 6E00           00018         MOVWF   PORTD
00000C 0000           00019         NOP
00000E EF04 F000      00020         GOTO    LOOP
                      00021 
Error[118]  : Overwriting previous address contents (0000)
Error[118]  : Overwriting previous address contents (0001)
Message[303]: Program word too large.  Truncated to core size. (005018EC)
Error[154]  : Each object file section must be contiguous (section .config_000000_TEST3.O)
Error[118]  : Overwriting previous address contents (0000)
Error[118]  : Overwriting previous address contents (0001)
                      00022         END
MPASM  5.51                         TEST3.ASM   4-2-2014  22:06:33         PAGE  2


SYMBOL TABLE
  LABEL                             VALUE 

LOOP                              00000008
MAIN                              00000004
__18F8722                         00000001
__DEBUG                           1


MEMORY USAGE MAP ('X' = Used,  '-' = Unused)

0000 : XXXXXXXXXXXXXXXX XX-------------- ---------------- ----------------
0000 : -XXXXXX-XXXXXX-- ---------------- ---------------- ----------------
1880 : ----XX---------- ---------------- ---------------- ----------------

All other memory blocks unused.

Program Memory Bytes Used:    32
Program Memory Bytes Free: 131040


Errors   :     7
Warnings :     0 reported,     0 suppressed
Messages :     1 reported,     0 suppressed

I'm really eager to actually get programming, so your help is, as always, really appreciated.

I've attached the .lst file when the #include isnt commented too.

Sparky
 

Attachments

Last edited:

JohnInTX

Joined Jun 26, 2012
4,787
Hmmm... don't see anything wrong yet.

You ARE in Absolute Mode yes?
Delete the CONFIG line entirely and try it that way for now. If it works, move CONFIG to the end of the source.

Error 303 is a mystery unless its a problem with the CONFIG directive. The assembler should know how to build code for its target processor. You should have the processor set to 18F8722 in the Configure->Select Device. The header file should complain if you don't but..

Did you start with a fresh project? It looks like its trying to link stuff, maybe duplicate .O files? Grasping at straws here. It may be a Windows 8.1/MPASM incompatibility.

Here's my source and list. Note the OrgAt: label. Build it and see what OrgAt evaluates to. It must be 00000.
 

Attachments

Thread Starter

Sparky49

Joined Jul 16, 2011
833
ORGA does go to 000000.

Still get the same error messages, even without CONFIG altogether. :|

Hmmm, I might send an email to microchip to find out if it is a Win 8.1 thing, tomorrow. :(

I am 99% sure I am in absolute mode, I checked the box and is says absolute, when I open the workspace I click absolute, so unless there is some hidden option somewhere that does something odd, we're in absolute.
 

JohnInTX

Joined Jun 26, 2012
4,787
Hmmm, I might send an email to microchip to find out if it is a Win 8.1 thing, tomorrow
I agree. You can submit a ticket through Technical Support from the main page of Microchip.com. You'll have to open an account with them if you don't have one. Zip and upload your project folder if you can. They'll notify you by email when they have it. You also get a telephone number to call on your issue.

Meanwhile, check out some of these.

Let us know how it works out. Sounds like a Toolchain / Win 8.1 issue. The code is fine. The fact that your label before ORG==0 means that there isn't any code there yet so no overwrite issues should occur.

I am 99% sure I am in absolute mode, I checked the box and is says absolute, when I open the workspace I click absolute, so unless there is some hidden option somewhere that does something odd, we're in absolute.
Sorry for the persistent questioning. It should have been working by now and I'm running out of easily testable ideas :confused:
 
Last edited:
Top