static int GlobalAccessS12XE(void) { int result; DWORD errorAddr; /* provide BDI info about the CPU type */ result = BDI_TargetStartup(100, (BDI_CPU_S12XE << 8) | 20, /* S12XEP100, BDM clock 2 MHz */ 0, 0); /* necessary in order to use global addresses */ result = BDI_FlashSetupHC12(BDI_CPU_S12XE, BDI_S12XE_DFLASH, 16, 0x8000, 0x2000); /* additiinal configuration */ result = BDI_SetByte(0x0100, 0x03); /* FCLKDIV: Set Flash clock divider for 4 MHz oscillator */ /* ..... */ /* load data to RAM */ printf("loading RAM ... "); result = BDI_LoadFile("e:/temp/test.sss", &errorAddr); if (result == BDI_OKAY) printf("passed\n"); else printf("failed\n"); /* dump data from RAM */ printf("dumping RAM ... "); result = BDI_DumpFile("e:/temp/ram.sss", 0x0FE000, 4096); if (result == BDI_OKAY) printf("passed\n"); else printf("failed\n"); return result; } /* GlobalAccessS12XE */ /**************************************************************************** **************************************************************************** TARGET_ReadByte: TARGET_ReadWord: TARGET_ReadLong: Read from a place in target memory. INPUT : addr Address of operand space address space OUTPUT : value data RETURN error code ****************************************************************************/ int TARGET_ReadByte(DWORD addr, WORD space, BYTE* value) { int result; result = BDI_MemoryRead(addr, space, 1, value); return result; } /* TARGET_ReadByte */ int TARGET_ReadWord(DWORD addr, WORD space, WORD* value) { int result; BYTE mem[2]; result = BDI_MemoryRead(addr, space, 2, mem); *value = (mem[0]<<8) + mem[1]; return result; } /* TARGET_ReadWord */ int TARGET_ReadLong(DWORD addr, WORD space, DWORD* value) { int result; BYTE mem[4]; result = BDI_MemoryRead(addr, space, 4, mem); *value = ((DWORD)mem[0]<<24) + ((DWORD)mem[1]<<16) + ((DWORD)mem[2]<<8) + (DWORD)mem[3]; return result; } /* TARGET_ReadLong */ /**************************************************************************** **************************************************************************** TARGET_WriteByte: TARGET_WriteWord: TARGET_WriteLong: Write to a place in target memory INPUT : addr Address of operand space address space data Value to write OUTPUT : RETURN error code INOUT : - ****************************************************************************/ int TARGET_WriteByte(DWORD addr, WORD space, BYTE data) { int result; result = BDI_MemoryWrite(addr, space, 1, &data); return result; } /* TARGET_WriteByte */ int TARGET_WriteWord(DWORD addr, WORD space, WORD data) { int result; BYTE mem[2]; mem[0] = (BYTE)(data>>8); mem[1] = (BYTE)(data>>0); result = BDI_MemoryWrite(addr, space, 2, mem); return result; } /* TARGET_WriteWord */ int TARGET_WriteLong(DWORD addr, WORD space, DWORD data) { int result; BYTE mem[4]; mem[0] = (BYTE)(data>>24); mem[1] = (BYTE)(data>>16); mem[2] = (BYTE)(data>>8); mem[3] = (BYTE)(data>>0); result = BDI_MemoryWrite(addr, space, 4, mem); return result; } /* TARGET_WriteLong */ int TARGET_WriteBlock(DWORD addr, WORD space) { int result; int i; BYTE data[1024]; for (i = 0; i < sizeof data; i++) data[i] = (BYTE)i; result = BDI_MemoryWrite(addr, space, sizeof data, data); return result; } /* TARGET_WriteBlock */