either 0x0800-0x084F (24HJ/24F) or 0x1000-0x104F (24EP). When you use XC16 this is done by the MPLAB project which defines a symbol __ICD2RAM for the linker .gld script, which takes care of reserving the memory space.
I thought maybe I could accomplish the same thing for Firewing by doing the following in my main bas file:
- Code: Select all
device = 24HJ128GP502
#define MPLAB_ICD = true
#if defined(MPLAB_ICD)
#warning "building for MPLAB_ICD"
#define _reserve_ICD = &H50 ' ICD requires 0x50 ram locations
#variable _xramstart = _xramstart + _reserve_ICD ' x RAM start in bytes
#variable _xram = _xram - _reserve_ICD ' x RAM size in bytes
#endif
It looked to me like that worked ok, but now I'm not so sure... I'm seeing variables getting overwritten when I try the following:
- Code: Select all
device = 24HJ128GP502
#define MPLAB_ICD = true
#if defined(MPLAB_ICD)
#warning "building for MPLAB_ICD"
#define _reserve_ICD = &H50 ' ICD requires 0x50 ram locations
#variable _xramstart = _xramstart + _reserve_ICD ' x RAM start in bytes
#variable _xram = _xram - _reserve_ICD ' x RAM size in bytes
#endif
imports uart
imports uarttypes
sub main()
dim b as byte
dim s as string
dim stat(16) as USTAReg
dim st, last_st as USTAReg
dim ix as ushort
dim wait as boolean
//--------------------------------------------------------------------------------------
uart.write("microstickII", 13, 10) // <<< THIS WRITE IS GARBLED
// when the code copies ROM to RAM it looks like [WREG14] is pointing into the middle of
// where the temp ram string buffer is located, and the temp ram string gets overwritten.
// it ends up writing "micros{" instead of "microstickII"
// the temp string starts at 0x0864, and WREG14 is 0x86A
//--------------------------------------------------------------------------------------
// the remaining code is just along for the ride...
delayms(100)
ix = 0
wait = false
st = uart.USTAT
last_st = st
erase(stat)
while (true)
while (wait)
end while
st = uart.USTAT
if (st <> last_st) then
last_st = st
stat(ix) = st
if (ix < ubound(stat)) then
ix += 1
end if
if (st.OERR = 1) then
uart.USTAT.OERR = 0
end if
if (st.FERR = 1) then
b = uart.RCREG
end if
if (st.URXDA = 1) then
b = uart.RCREG
end if
end if
end while
end sub
I guess I'm causing some sort of allocation issue by moving the start of ram?
