Hello!
I have a big trouble writing in P-Flash. I am able to erase and read a section. However I cannot write 16 bytes on a specific memory.
To erase the flash the command 0x09 is employed and to write the employed command is 0x06.
I have read the datasheet and everything seems to be fine. But I do not know what can be wrong.
static void ftfl_command( unsigned char command, unsigned long *address, unsigned long data )
{
uint32 temp_reg;
temp_reg = FMC_PFAPR; /* store present value of FMC_PFAPR */
/* Set M0PFD through M7PFD to 1 to disable prefetch */
FMC_PFAPR |= FMC_PFAPR_M7PFD_MASK | FMC_PFAPR_M6PFD_MASK |
FMC_PFAPR_M5PFD_MASK | FMC_PFAPR_M4PFD_MASK |
FMC_PFAPR_M3PFD_MASK | FMC_PFAPR_M2PFD_MASK |
FMC_PFAPR_M1PFD_MASK | FMC_PFAPR_M0PFD_MASK |
FMC_PFAPR_M0AP_MASK | FMC_PFAPR_M1AP_MASK |
FMC_PFAPR_M2AP_MASK | FMC_PFAPR_M3AP_MASK |
FMC_PFAPR_M4AP_MASK | FMC_PFAPR_M5AP_MASK |
FMC_PFAPR_M6AP_MASK | FMC_PFAPR_M7AP_MASK ;
FMC_PFB01CR &= 0xFFFFFFE6; /* Single entry buffer disable.*/
FMC_PFB23CR &= 0xFFFFFFE6; /* Single entry buffer disable. */
FMC_PFB01CR &= 0xFFFFFFF9; /* Data Cache disable. */
FMC_PFB23CR &= 0xFFFFFFF9; /* Data Cache disable. */
irq_desc = cpu_irq_disable();
while (!(FTFE_FSTAT & FTFE_FCNFG_CCIE_MASK))
{};
FTFE_FSTAT = (FTFE_FSTAT_ACCERR_MASK | FTFE_FSTAT_FPVIOL_MASK | FTFE_FSTAT_RDCOLERR_MASK);
FTFE_FCCOB0 = command;
FTFE_FCCOB1 = (fnet_uint8)(((fnet_uint32)address) >> 16); /* Flash address [23:16] */
FTFE_FCCOB2 = (fnet_uint8)(((fnet_uint32)address) >> 8); /* Flash address [15:8] */
FTFE_FCCOB3 = (fnet_uint8)((fnet_uint32)address); /* Flash address [7:0] */
FTFE_FCCOB4 = (fnet_uint8)(data >> 24); /* Data Byte 0.*/
FTFE_FCCOB5 = (fnet_uint8)(data >> 16); /* Data Byte 1.*/
FTFE_FCCOB6 = (fnet_uint8)(data >> 8); /* Data Byte 2.*/
FTFE_FCCOB7 = (fnet_uint8)(data); /* Data Byte 3.*/
fftfl_command_lunch_inram();
FMC_PFAPR = temp_reg;
cpu_irq_enable(irq_desc);
}
Best regards.
Solved! Go to Solution.
Hello Juan:
Command 0x06 is not supported by K60FX512 (FTFE Flash module). Instead you should use the 0x07 command (Program Phrase). This command is to write 8 bytes (64 bits) at once.
Also, be careful that the address at which you want to write data is aligned to 64 bits, so the 6 least significant bits of the address must be 0.
Regards!
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Juan:
Command 0x06 is not supported by K60FX512 (FTFE Flash module). Instead you should use the 0x07 command (Program Phrase). This command is to write 8 bytes (64 bits) at once.
Also, be careful that the address at which you want to write data is aligned to 64 bits, so the 6 least significant bits of the address must be 0.
Regards!
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------