This works without a problem, except I have to look up the structure of the call every time I add one. Also the readability is not exactly great. a structure in upper 64 k of "code flash" in a SILabs f122typedef struct { U32 MSFC_tag; // 'MSFC' Multi-Size Font Collection // MSFC U32 MSFC_idno; // random unique font id number (referenced by subfonts if split) // fb06c05c U8 MSFC_ver; // file version (set to 1) // 01 U8 MSFC_tblcnt; // number of table dir entries following // 03 U8 MSFC_sftcnt; // number of subfonts contained in / belonging to this collection // 01 U8 MSFC_flags; // 0 for standard CBFs (bit0=1 for vertical font) // 01 U16 MSFC_fsiz; // Complete size of the file (max size is 65534 (= 0xfffe) bytes) // 061a } STR_MSFC; a function //////////////////////////////////////////////////////////// // // // FUNCTION U32 ReadFlashLong (U8 code * RFSaddr) // // read high flash // U32 ReadFlashLong (U8 code *RFSaddr) { U8 RFCintsav; U8 RFCdata; U8 code * RFSadds; U32 RFScomp; RFCintsav = SG_IE; SG_IE = 0; SG_SFRPAGE = 0; if (RFSaddr > 0x7fff) { SG_PSBANK = 0x30; } else { SG_PSBANK = 0x20; RFSaddr += 0x8000 ; } RFSadds = RFSaddr; for (RFCdata = 0 ; RFCdata < 4 ;RFCdata++, RFSadds++) { RFScomp <<= 8; RFScomp |= (U32) *RFSadds; } SG_IE = RFCintsav; return (RFScomp) ; } the call s_msfc = 0 ; if ( FFS_CfntNo == 2) { s_msfc = 0x8000 ; } FFSLtemp = ReadFlashLong ((U8 code *) &s_msfc->MSFC_tag); what would be "natural" FFSLtemp = ReadFlashLong (s_msfc->MSFC_tag) gives error; is there a simpler way to make the call without specifying a pointer to something now specified as a pointer (asx seen in bold above). I am NOT interested in a suggestion about using "banking" my other routines do not have the time to go through a bank check/switch. I am using a 100Mips '51 and can hardly keep up. Also, the shorts and longs are in the wrong order because the files with these structures are generated on a PC so, even using "banking" would not totally solve the problem. Erik
"1) it is not xdata, it is code" Doesn't this chip give you the option to map (some of) the flash into XDATA space?
not that I know of, but then the datasheet is 350 pages. Anyhow it is irrelevant since I never write to it with this code. Erik actually to write to it you need this
//////////////////////////////////////////////////////////// // // // FUNCTION void WriteFlash (U8 xdata * WFSaddr, U8 WFCdata) // // read high flash // void WriteFlash (U8 xdata * WFSaddr, U8 WFCdata) { U8 WFCintsav; WFCintsav = SG_IE; SG_IE = 0; SG_SFRPAGE = 0x0f; SF_CCH0CN &= 0xfe; // single byte write SG_SFRPAGE = 0; if (WFSaddr > 0x7fff) { SG_PSBANK = 0x30; } else { SG_PSBANK = 0x20; WFSaddr += 0x8000 ; } S0_FLSCL |= 0x01 ; // flash write S0_PSCTL |= 0x01 ; // movx to flash *WFSaddr = WFCdata ; //write the byte S0_PSCTL &= 0xfe ; // restore S0_FLSCL &= 0xfe ; // restore SG_PSBANK = 0x10 ; SG_IE = WFCintsav; }
"it is irrelevant since I never write to it with this code." That's irrelevant! The point of XDATA banking in this context is that it maps constants (which would normally be in CODE) into XDATA space. That said, I don't know if it's actually of any use to you! Maybe a red herring?