2011-11-11 09:53 PM
In the application we are using stm32f103zet6 high density ARM controller. We r trying to write array of data to flash memory. We r just able to write 4 words with ProgramHalfWord function,
my program segment goes like this //some of the macros listed //Embedded Flash Configuration #define __EFI_ACR_Val 0x00000012 /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Flash Access Control Register bits */ #define ACR_LATENCY_Mask ((u32)0x00000038) #define ACR_HLFCYA_Mask ((u32)0xFFFFFFF7) #define ACR_PRFTBE_Mask ((u32)0xFFFFFFEF) /* Delay definition */ #define EraseTimeout ((u32)0x00000FFF) #define ProgramTimeout ((u32)0x0000000F) Addr = 0x08010000;//32nd page address for(k=0;(k<40 && FLASHStatus == FLASH_COMPLETE);k = k+1)//loop for 40 32bit memory data { T.val = DB9[k];//DB9[] is array of u32 type data = T.bytes.lowByte; //data is u16 type, used union to split 32 bit data //lower 16 bits FLASHStatus = FLASH_ProgramHalfWord(Addr, data); // Addr = Addr + 2;//increment address by 2 while(FLASHStatus != FLASH_COMPLETE);//wait until FLASH_COMPLETE data = T.bytes.highByte;////data is u16 type, used union to split 32 bit data //higher 16 bits FLASHStatus = FLASH_ProgramHalfWord(Addr, data); // Addr = Addr + 2; while(FLASHStatus != FLASH_COMPLETE);//wait until FLASH_COMPLETE } My controller is operated with 72MHz Any problem with Erase timeout or program timeout?2011-11-12 05:50 AM
data = T.bytes.lowByte; //data is u16 type, used union to split 32 bit data //lower 16 bit
Why would you refer to a 16-bit value in a union as a ''byte''while(FLASHStatus != FLASH_COMPLETE);//wait until FLASH_COMPLETE What exactly happens with your while() loops? Because FLASHStatus isn't going to magically change. The code will lock up and fail if the memory is not erased (word = 0xFFFF prior to write). You don't use the timeouts, but look to be hard coded values. For accurate timing loops, consider using the core cycle counter.