The problem is that I fall into an illegal ISR trap when implementing fopen. The code also includes a custom memory to operate a complex FFT routine. This trap does not occur when that additional code is removed and the only code is to operate the cio commands.
I did an assembly step into at the fopen command and the following things occur.
C$DW$L$_USB_Read$2$E, C$L3: c++ code program line 144
009b6a: 8F00C3E0 MOVL XAR4, #0x00c3e0
009b6c: 8F40C412 MOVL XAR5, #0x00c412
009b6e: 764099E2 LCR fopen line of code branches to fopen function here
009b70: A846 MOVL *-SP[6], XAR4
146 i = 0;
009b71: 761F0280 MOVW DP, #0x280
009b73: 2B01 MOV @0x1, #0
fopen:
0099e2: AABD MOVL *SP++, XAR2 When stepping into this instruction I get an error: fopen(* char, * char) at tmp/TI_MKLIBOv0gl0/SRC/fopen.c:73 0x99e2
0099e3: 761F0304 MOVW DP, #0x304
0099e5: A2BD MOVL *SP++, XAR3
0099e6: C53E MOVL XAR7, @0x3e
0099e7: 86A5 MOVL XAR2, @XAR5
0099e8: 82A4 MOVL XAR3, @XAR4
0099e9: FE02 ADDB SP, #2
0099ea: 3E67 LCR *XAR7
0099eb: 764099AF LCR _search_fp When stepping into this instruction it enters the illegal ISR trap.
The problem is I am unsure of what fopen is attempting to do to cause the errors. Plus, this does not occur in the more stripped down version of the code (IO file reads only).
My memory map looks like:
MEMORY
{
PAGE 0 :
/* BEGIN is used for the "boot to SARAM" bootloader mode */
BEGIN : origin = 0x000000, length = 0x000002 /* Boot to M0 will go here */
BOOT_RSVD : origin = 0x000002, length = 0x00004E /* Part of M0, BOOT rom will use this for stack */
RAMM0 : origin = 0x000050, length = 0x0003B0
RAML0 : origin = 0x008000, length = 0x004000
RAML1 : origin = 0x00C000, length = 0x001000
// RAML2 : origin = 0x00A000, length = 0x001000
// RAML3 : origin = 0x00B000, length = 0x001000
ZONE7A : origin = 0x200000, length = 0x00FC00 /* XINTF zone 7 - program space */
CSM_RSVD : origin = 0x33FF80, length = 0x000076 /* Part of FLASHA. Program with all 0x0000 when CSM is in use. */
CSM_PWL : origin = 0x33FFF8, length = 0x000008 /* Part of FLASHA. CSM password locations in FLASHA */
ADC_CAL : origin = 0x380080, length = 0x000009
RESET : origin = 0x3FFFC0, length = 0x000002
IQTABLES : origin = 0x3FE000, length = 0x000b50
IQTABLES2 : origin = 0x3FEB50, length = 0x00008c
FPUTABLES : origin = 0x3FEBDC, length = 0x0006A0
BOOTROM : origin = 0x3FF27C, length = 0x000D44
PAGE 1 :
RAMM1 : origin = 0x000400, length = 0x000400 /* on-chip RAM block M1 */
RAML2 : origin = 0x00A000, length = 0x0021DE
RAML3 : origin = 0x00C1DE, length = 0x000F24
RAML4 : origin = 0x00D102, length = 0x001000
RAML5 : origin = 0x00E102, length = 0x001000
RAML6 : origin = 0x00F102, length = 0x001000
RAML7 : origin = 0x010102, length = 0x001000
ZONE7B : origin = 0x20FC00, length = 0x000400 /* XINTF zone 7 - data space */
SYSMEM : origin = 0x3F8000, length = 0x001000 /* Added for sysmem --heap location*/
CIO : origin = 0x3F9000, length = 0x004000 /* Added for CIO loaction) */
}
SECTIONS
{
/* Setup for "boot to SARAM" mode:
The codestart section (found in DSP28_CodeStartBranch.asm)
re-directs execution to the start of user code. */
codestart : > BEGIN, PAGE = 0
ramfuncs : > RAML0, PAGE = 0
/* .text : > RAML1, PAGE = 0 */
.text : > RAML0, PAGE = 0
.cinit : > RAML0, PAGE = 0
.pinit : > RAML0, PAGE = 0
.switch : > RAML0, PAGE = 0
.stack : > RAMM1, PAGE = 1
.ebss : > RAML2, PAGE = 1
.econst : > RAML3, PAGE = 1
.esysmem : > RAMM1, PAGE = 1
.sysmem : > SYSMEM, PAGE = 1
.cio : > CIO, PAGE = 1
CFFTdata1 : > RAML4, PAGE = 1, ALIGN(512)
CFFTdata2 : > RAML5, PAGE = 1
CFFTdata3 : > RAML6, PAGE = 1
CFFTdata4 : > RAML7, PAGE = 1
IQmath : > RAML1, PAGE = 0
IQmathTables : > IQTABLES, PAGE = 0, TYPE = NOLOAD
/* Uncomment the section below if calling the IQNexp() or IQexp()
functions from the IQMath.lib library in order to utilize the
relevant IQ Math table in Boot ROM (This saves space and Boot ROM
is 1 wait-state). If this section is not uncommented, IQmathTables2
will be loaded into other memory (SARAM, Flash, etc.) and will take
up space, but 0 wait-state is possible.
*/
/*
IQmathTables2 : > IQTABLES2, PAGE = 0, TYPE = NOLOAD
{
IQmath.lib<IQNexpTable.obj> (IQmathTablesRam)
}
*/
FPUmathTables : > FPUTABLES, PAGE = 0, TYPE = NOLOAD
DMARAML4 : > RAML4, PAGE = 1
DMARAML5 : > RAML4, PAGE = 1
DMARAML6 : > RAML4, PAGE = 1
DMARAML7 : > RAML4, PAGE = 1
ZONE7DATA : > ZONE7B, PAGE = 1
.reset : > RESET, PAGE = 0, TYPE = DSECT /* not used */
csm_rsvd : > CSM_RSVD PAGE = 0, TYPE = DSECT /* not used for SARAM examples */
csmpasswds : > CSM_PWL PAGE = 0, TYPE = DSECT /* not used for SARAM examples */
/* Allocate ADC_cal function (pre-programmed by factory into TI reserved memory) */
.adc_cal : load = ADC_CAL, PAGE = 0, TYPE = NOLOAD
}