/**************************************************************************** **************************************************************************** ProgramMPC555 : Program internal flash of MPC555. INPUT : - OUTPUT : RETURN error code ****************************************************************************/ #define MPC555_CLOCK 40000000 #define MPC555_WORKSPACE 0x003FC000 static BDI_InitTypeT mpc555InitList[] = { {BDI_INIT_PPC_WMSR, 0, 0x00003002}, // MSR : set FP,ME,RI {BDI_INIT_PPC_WSPR, 27, 0x00003002}, // SRR1: set FP,ME,RI {BDI_INIT_PPC_WSPR, 638, 0x00000800}, // IMMR: InternalRegs to 0x00000000, Flash enabled {BDI_INIT_PPC_WSPR, 158, 0x00000007}, // ICTRL : ICTRL: not serialized, no show cycles {BDI_INIT_PPC_WM32, 0x002FC004, 0xFFFFFF01}, // SYPCR : disable watchdog {BDI_INIT_PPC_WM32, 0x002FC284, 0x00110000} // PLPRCR: 40MHz clock }; static int ProgramMPC555(void) { int result; DWORD errorAddr; result = BDI_FlashSetup555(BDI_MPC555_FLASH, MPC555_CLOCK, MPC555_WORKSPACE); result = BDI_TargetStartup(0, MPC555_CLOCK, sizeof mpc555InitList / sizeof mpc555InitList[0], mpc555InitList); result = BDI_FlashErase555(0x00000000, 0xFFFC0000, FALSE, MPC555_CLOCK, MPC555_WORKSPACE); result = BDI_FlashWrite555("E:\\temp\\test.s19", &errorAddr); return result; } /* ProgramMPC555 */ static BYTE data555SA[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; static int ProgramMPC555SA(void) { int result; DWORD errorAddr; result = BDI_FlashSetup555(BDI_MPC555_SHADOW, MPC555_CLOCK, MPC555_WORKSPACE); result = BDI_TargetStartup(0, MPC555_CLOCK, sizeof mpc555InitList / sizeof mpc555InitList[0], mpc555InitList); result = BDI_FlashWriteBlock(0x20, sizeof data555SA, data555SA, &errorAddr); result = TARGET_WriteLong(0x002FC800, 0x8C000000); // CMFMCR: Enable shadow information result = BDI_VerifyBlock(0x20, sizeof data555SA, data555SA, &errorAddr); return result; } /* ProgramMPC565 */ /**************************************************************************** **************************************************************************** ProgramMPC565 : Program internal flash of MPC565. INPUT : - OUTPUT : RETURN error code ****************************************************************************/ #define MPC565_CLOCK 20000000 #define MPC565_WORKSPACE 0x003FC000 static BDI_InitTypeT mpc565InitList[] = { {BDI_INIT_PPC_WMSR, 0, 0x00003002}, // MSR : set FP,ME,RI {BDI_INIT_PPC_WSPR, 27, 0x00003002}, // SRR1: set FP,ME,RI {BDI_INIT_PPC_WSPR, 638, 0x00000800}, // IMMR: InternalRegs to 0x00000000, Flash enabled {BDI_INIT_PPC_WSPR, 158, 0x00000007}, // ICTRL : ICTRL: not serialized, no show cycles {BDI_INIT_PPC_WM32, 0x002FC004, 0xFFFFFF01}, // SYPCR : disable watchdog // {BDI_INIT_PPC_WM32, 0x002FC284, 0x0091C000} // PLPRCR: 40MHz clock }; static int ProgramMPC565(void) { int result; DWORD errorAddr; result = BDI_FlashSetupUC3F(BDI_UC3F_FLASH, MPC565_WORKSPACE); result = BDI_InitListReset(); result = BDI_InitListAdd(BDI_INIT_PPC_WMSR, 0, 0x00003002); result = BDI_InitListAdd(BDI_INIT_PPC_WSPR, 27, 0x00003002); result = BDI_InitListAdd(BDI_INIT_PPC_WSPR, 638, 0x00000800); result = BDI_InitListAdd(BDI_INIT_PPC_WSPR, 158, 0x00000007); result = BDI_InitListAdd(BDI_INIT_PPC_WM32, 0x002FC004, 0xFFFFFF01); result = BDI_TargetStartup(100, MPC565_CLOCK, 0, NULL); /* standard way using a table for the init list: result = BDI_TargetStartup(100, MPC565_CLOCK, sizeof mpc565InitList / sizeof mpc565InitList[0], mpc565InitList); */ printf("erasing ..."); result = BDI_FlashEraseUC3F(0x00000000, 0x00F0, FALSE, MPC565_WORKSPACE); if (result != BDI_OKAY) return result; result = BDI_FlashEraseUC3F(0x00000000, 0x000F, FALSE, MPC565_WORKSPACE); if (result != BDI_OKAY) return result; result = BDI_FlashEraseUC3F(0x00080000, 0x00F0, FALSE, MPC565_WORKSPACE); if (result != BDI_OKAY) return result; result = BDI_FlashEraseUC3F(0x00080000, 0x000F, FALSE, MPC565_WORKSPACE); if (result != BDI_OKAY) return result; printf("passed\n"); return result; printf("programming..."); result = BDI_FlashWriteFile("D:/abatron/bdi360/ppc/pro/mpc565.sss", &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifing ..."); result = BDI_VerifyFile("D:/abatron/bdi360/ppc/pro/mpc565.sss", &errorAddr); printf("passed\n"); return result; } /* ProgramMPC565 */ static BYTE data565SA[] = {1,2,3,4,5,6,7,8}; static int ProgramMPC565SA(void) { int result; DWORD errorAddr; result = BDI_FlashSetupUC3F(BDI_UC3F_SHADOW, MPC565_WORKSPACE); result = BDI_TargetStartup(0, MPC565_CLOCK, sizeof mpc565InitList / sizeof mpc565InitList[0], mpc565InitList); result = TARGET_WriteLong(0x002FC804, 0xC0000000); // MCRE : Enable Small Blocks in module A result = BDI_FlashEraseUC3F(0x00000000, 0x0200, FALSE, MPC565_WORKSPACE); result = BDI_FlashWriteBlock(0x10, sizeof data565SA, data565SA, &errorAddr); result = TARGET_WriteLong(0x002FC800, 0x48000000); // CMFMCR: Enable shadow information result = BDI_VerifyBlock(0x10, sizeof data565SA, data565SA, &errorAddr); return result; } /* ProgramMPC565 */