Charles Patton - 2015-06-09

I've been using Great Cow BASIC Version: 0.9 16/6/2009 for some
5 years in projects with the PIC12F683. I recently had need to
set a default value in the EE memory that requires use of a MPASM
compiler command. Searching the forums turned up:
http://sourceforge.net/p/gcbasic/discussion/596084/thread/40ac369b/
In essence the technique hand edit/appends the EE memory data to the
end of the GCB generated .ASM file. A simple example:

main GCB pgm .ASM output
..
ORG 0x2100 ;inserted
DE 2 ; value of 2 or any other single byte inserted
END

I wanted a cleaner inline solution that stays with the original
source code and here it is:

.. HEADERS - #CHIP DECLARATIONS, ETC.
.. VARIABLE DECLARATIONS
..
UNIQUE: 'any name to allow GCB to know current code address value
ASM ORG 0x2100 'required magic EEmem adr for PIC12xxx
ASM DE VALUE 'DE = directive to MPASM for programmer
'EEmem write
'VALUE = byte value desired to be put in EEmem
'can also be a quoted string of text or comma separated values
'see the original forum article ref above
' or pg. 64 of MPASM directives in
' http://ww1.microchip.com/downloads/en/DeviceDoc/33014K.pdf
ASM ORG UNIQUE 'reset code address to continue
'where we left off
.. the rest of the GCB pgm code
END

The GCB compiler accepts this and the MPASM will accept the .ASM output and place the EEmem setting code in the .HEX file at the same place as if it had been hand edited to the end. The .ASM files are different, but the .HEX files have exactly the same cksums by either method and match in the "Diffuse Merge Tool", but by using the new technique the source GCB file requires only compiling to .ASM and no further hand editing.

A discussion at:
http://www.microchip.com/forums/m810541.aspx
points out the address used to load the EEmem changes for different PIC families:
Most PIC1x MCUs - 0x2100
PIC18 MCUs - 0xF00000
PIC16F19xx MCUs - 0xF000

Hope this helps with using GCB to add EE memory programming inline
code.

 

Last edit: Charles Patton 2015-06-09