Hello,
I've still been unable to successfully load the H7F Flash drivers into the MPC5566's RAM and execute them with the intention of using the drivers to load a new program into the MPC5566's Flash. I'm using an ATmega64M1 to interface with the MPC5566 through the JTAG. To date, I've been able to:
1. Initialize the JTAG TAP controller.
2. Enable the OnCE.
3. Enter external debug mode.
4. Read and write the OSR, CPUSCR, GPRs, SPRs, and the internal SRAM in both single and burst modes.
5. Exit debug mode.
It seems I have the main pieces tested and ready to start exercising the Flash drivers, but here's where I'm having trouble.
1. When I write the MAS0-3 registers and execute the tlbwe instruction to set up the addresses (as in Table 9 of the AN3283 for non-VLE Flash drivers running in internal SRAM), the write appears to work properly, but when I read the MMU back, the value that was set in MAS3 is now in MAS0, MAS1, MAS2, and MAS3.
2. When I attempt to initialize the SRAM, the initialization takes several minutes. My routine sets the SRAM beginning address to 0x40000000 and the SRAM size to 0x1FFFF / 0x80. It then loops through SRAM size times, and does the following:
a. registerVal = sramBegin + (i * 0x80);
b. writes CPUSCR->WBBRlo with the registerVal, and CPUSCR->IR with the stmw instruction.
c. Single Steps through the stmw instruction.
3. When I set up the FMPLL, I'm not sure that I have the correct values because my program never returns from the function, but here is the process:
a. Save the FMPLL_SYNC register address to GPR3.
b. Save the new value to be written to FMPLL_SYNC to GPR4. The value is (MSB first) = 0b 0000 0000 0000 0000 0000 1001 0000 0000, which should set the Fref to 8 MHz crystal, PREDIV to 0b000 (divide by 1, default), MFD = 0b10000 (16), RFD = 0b001 (2), Fsys = 8 * (20 / 2^2) = 40 MHz.
c. Execute the lwarx instruction, where GPR3 contains the address of word to be loaded and replaced. The word is temporarily stored in GPR5 while a reservation of the memory location in GPR3 is created.
d. Execute the stwcx instruction, which stores the contents of GPR4 into the reserved memory at GPR3.
e. Execute msync between the write to FMPLL_SYNC[MFD] and the read of FMPLL_SYNSR[LOCK]
f. Read the data at FMPLL_SYNSR to GPR5 and poll the FMPLL_SYNSR[LOCK] bit to see when it is set. My program hangs here.
Any help with these issues would be greatly appreciated. Thank you in advance!
Rebecca