AnsweredAssumed Answered

K60FX512 problem writing to P-Flash

Question asked by Juan A. on Mar 2, 2015
Latest reply on Mar 4, 2015 by Jorge_Gonzalez

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.

Outcomes