I am quite new to the PICs and especially with XC8 pic-as and MPLAB-X
I have a ultra minimal project i am working on, and i have some questions regarding the OSCCAL values located at the reset vector, and how to "not specify" them (for programming) while still be able to debug the program using the simulator.
Here is my code :
radix dec
processor 10F202
CONFIG WDTE = OFF
CONFIG CP = OFF
CONFIG MCLRE = OFF
#include "xc.inc"
; PSECT resetVector, class=CODE
;resetVector:
; MOVLW 14h
PSECT main, class=CODE
main:
MOVLW 1
GOTO main
END
When compiling and linking with additional flags -Wl,-pmain=0h i get this hex file (nothing at 0x1FF which is the reset vector and the MOVLW instruction to load the OSCCAL value)
:0300000001000AF2
:021FFE00EB0FE7
:00000001FF
I have not flashed that program, as i do not yet have a programmer, but it looks "okay".
Problem #1 : i cannot use the simulator to test the code, as it complains there is no section at 01FFh (the reset vector, which will then wrap around to 000h)
No source code lines were found at current PC 0x1ff.
Use Program memory view to see instruction code disassembly.
If i then add a section to "simulate" the resetVector (MOVLW OSCCAL) by uncommenting the above section, and compile it with additionnal linker flags -Wl,-presetVector=1FFh i get the folling hex file :
:0300000001000AF2
:0101FF0014EB
:021FFE00EB0FE7
:00000001FF
There is a proper OSCCAL value of 14h loaded at 01FFh, and the simulator will start ok.
Problem #2 : if i would program a chip with this hex file, will it override the OSCCAL value already on the chip from factory calibration, by the value present in the hex file ? Or is it smart enough to ignore the value in the hex file, or rewrite the previous one after programming ?
Additionnal question #3 : is there any better way to specify section addresses than linker flags ? Using linker flags feels like more like a workaround than a feature or an ergonomic way to do this (and you have to add/remove flags everytime you modify your sections, which is cumbersome)
Thanks in advance for your insights.
-DCODE=2linker option, which on its own does not produce 2-bytes par word hex file : eachpsectneeds its owndelta=2flag to produce a 2 bute per word hex. Any idea why the option seems ignored ?