2006-10-30 04:52 AM
2006-10-30 01:30 AM
Hi
I am running the IAR IDE and I am trying to program 3 Words to flash B0F7. I am running from lower banks of B0. At address 0x030000 I have defined a table where 3 words must be written over at a latter time. However the rest of the table must remain intact so I cannot erase the sector. The 3 words are set to 0xFF when the program is written to Flash. I do disable the write protection of B0F7 prior to the writes. The peculiar thing is that if I step through the code the 3 words are programmed fine, but if I am running nothing gets programmed. Help !2006-10-30 02:29 AM
Can you post your code here? One thing that can be happening is that you are not waiting for the program operation to finish.
Regards, - mike2006-10-30 02:33 AM
Hi Mike
Here is an extract of my code: I have tried WordWrite located both in RAM and Flash. __ramfunc void FLASH_MYWordWrite(u32 XtargetAdd, u32 Xdata) { // FLASH_WaitForLastTask(); // set the Word Programming bit 'WPG' in the CR0 Reg FLASHR->CR0 |= FLASH_WPG_Mask; // Load the destination address in AR FLASHR->AR = XtargetAdd; // Load DATA to be programmed in DR0 FLASHR->DR0 = Xdata; // Set the Write Mode Start bit 'WMS' in the CR0 Reg to Start Write Operation FLASHR->CR0 |= FLASH_WMS_Mask; // Wait until the write operation is completed // FLASH_WaitForLastTask(); } unsigned char USB_Set_SerialNo( char *buf ) { unsigned char success = 0; long address = 0x0030064; char tmp[20]; int i, j, pos; long data1; if ( (strncmp( ''Set_SerialNo'', buf, 12)) == 0 ) { success = 1; if ( strlen( buf ) != 20 ) return( 2 ); /* Disable the FLASH protection on Bank 0 sector 7 */ FLASH_WritePrConfig (FLASH_B0F7,DISABLE); pos = 13; for ( j=0; j { i=0; tmp[i++] = buf[pos++]; tmp[i++] = 0; tmp[i++] = buf[pos++]; tmp[i++] = 0; memcpy( &data1, tmp, 4 ); FLASH_WaitForLastTask(); FLASH_MYWordWrite (address, data1) ; FLASH_WaitForLastTask(); address +=4 ; } FLASH_WritePrConfig (FLASH_B0F7,ENABLE) ; } return( success ); }2006-10-30 03:03 AM
The code looks right. Just one question: is FLASH_WaitForLastTask() declared as __ramfunc?
- mike2006-10-30 03:07 AM
Hi Mike
No the FLASH_WaitForLastTask() is not define in RAM. However I will try it right now. Yvon2006-10-30 03:24 AM
Hi Mike
Locating FLASH_WaitForLastTask() in Ram made no difference. Yvon2006-10-30 03:41 AM
Hi Mike
By Locating both FLASH_WaitForLastTask() and FLASH_WordWrite() in RAM and using Bank 1 Sector 1 everything works properly. It still does not explain why I can't use Bank 0 Sector 7. And yes I am using an STR711FR2. Thanks Yvon2006-10-30 04:31 AM
You should call FLASH_WaitForLastTask() from within FLASH_MYWordWrite(), otherwise the CPU steps out of the RAM function into a ROM function, the code of which is invalid during flash programming. Just uncomment FLASH_WaitForLastTask() at the last line of FLASH_MYWordWrite().
- mike2006-10-30 04:52 AM
Hi Mike
I did that and it now appear to work also in Bank0 Sector7. Thanks Yvon