Oren Lavi

ColdFire 52235: Program Flash

Discussion created by Oren Lavi on Jul 26, 2006
Latest reply on Jun 20, 2008 by Cristiano Cortezia
Hello
 
I am trying to program the flash (coldfire 52235).
I didn't success to burn the flash.
I am working with the EVB board with 25Mhz oscillator.
 
Can someone tell me please what's wrong with my code?
 
LCF file:
 
Code:
MEMORY{    flash   (RX)   : ORIGIN = 0x00000000, LENGTH = 0x00040000 vectorram(RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000400 sram (RWX)  : ORIGIN = 0x20000400, LENGTH = 0x00007C00 ipsbar  (RWX)  : ORIGIN = 0x40000000, LENGTH = 0x0}C file:#define FLASH_PROGRAM_ADDR(x) \  (*(volatile unsigned long *)(void *)(&__IPSBAR[(0x04000000 + (x))]))#define ACCERR  0x10#define PVIOL  0x20#define CCIF  0x40#define CBEIF  0x80//Assume Crystal Oscillator = 25Mhzvoid InitCpuFreq(void){  MCF_CLOCK_SYNCR=0x4007;//Multiply By 12 (Divide By 5 Later),PLL Enable }void SetFlashBurnFreq(void){ MCF_CFM_CFMMCR=0;//No Lock,Interrupt Disable MCF_CFM_CFMCLKD=0x55;//Set Freq To About ~178Khz  MCF_CFM_CFMPROT=0;//No Sector Is Protect MCF_CFM_CFMSACC=0;//Flash Sectors Are Placed In Supervisor Address  MCF_CFM_CFMDACC=0;}int runInRam(char cmd, long addr, long val) { MCF_CFM_CFMUSTAT = PVIOL | ACCERR; FLASH_PROGRAM_ADDR(addr)=val; MCF_CFM_CFMCMD = cmd; MCF_CFM_CFMUSTAT = CBEIF; while (!(MCF_CFM_CFMUSTAT & (CCIF | PVIOL | ACCERR))); return MCF_CFM_CFMUSTAT & (PVIOL | ACCERR);}void runEnd(void){} // leave this immediately after runInRam  //The function to program an array of longs, for instance:  int flashProg(long *Addr, long *Value, int n) { char buf[120]; int (*ramCopy)(char,long,long) = (int(*)(char,long,long))buf; memcpy(buf, (void*)runInRam, (char*)runEnd - (char*)runInRam); while (n--)  {  if (ramCopy(0x20/*CMDPROG*/, Addr[n-1], Value[n-1])) return -1; } return 0;}void main (void){long Addr[2]=    {     0x6000,     0x6004     };    long Value[2]=     {     0xAA55AA55,     0x55AA55AA      };InitCpuFreq(); SetFlashBurnFreq();    flashProg(Addr, Value,  2);}

 
 
Thanks
 
 
 
 

Message Edited by Alban on 2006-08-07 06:38 AM

Outcomes