0

i am trying to make an erase for flash memory from main.c, when i put a breakpoints in debugger (isystem ic5700 ) it erase succefully. when i am trying to run the programm without any breakpoint , exception happens . i read the status register of FTFC_FSTAT and i found that bit RDCOLERR indicates that a collision erro happens .

  • 3
    Without sight of the code an an indication of where you place the break point, how can we tell!? Section 8.1 in [this app note](https://www.nxp.com/docs/en/application-note/AN11983.pdf) discussed RDCOLERR and its causes. The error is certainly in your code, but you have not provided that. Flash write operations are asynchronous to the processor execution; I imagine you have started flash some operation, and failed to wait for it to complete before starting the next. When you hit the break-point the operation has time to complete. That's just a guess. – Clifford Mar 29 '19 at 19:13
  • i am writing the FCCOB register with adresses and commands then i clear the CCIF flag and waiting for it to be set to 1 again , i am running all that operation from functin i put it in the ram . – ibrahim mostafa Mar 29 '19 at 21:30
  • i don't have an access now , but this the bseudo code for the last line that i doubt . clear CCIF flag to lauunch the command. While (CCIF flag ==1) { } – ibrahim mostafa Mar 29 '19 at 22:08
  • 1
    Well, there you are. The CCIF flag is zero while the operation is in progress. So you need `while( CCIF == 0 ){ }`. – Clifford Mar 29 '19 at 23:11
  • so sorry i meant != , i have check it already while(bit_is_set(FTFC,CCIF) !=1) {} – ibrahim mostafa Mar 29 '19 at 23:19
  • 1
    You need to place that information in your question not comments. We cannot answer the temporary comments, only the question. Explicitly testing the value of a Boolean function is unnecessary, error prone and generally bad form, and in this case confusing - better `while( !bit_is_set(FTFC,CCIF) ) { }`. Even better: `while( bit_is_clear(FTFC,CCIF) ) { }`, or `loop_until_bit_is_set(FTFC,CCIF)` (these being other macros defined in ``). – Clifford Mar 30 '19 at 00:36
  • This phenomenon is common when you try to execute the code from the same bank that you are programming. It may then work by luck when single-stepping, even though the manufacturer makes no such guarantees. Same if you picked the wrong flash pre-scaler clock. And needless to say, all interrupts meddling with the flash to be programmed must be shut-off or told to work with RAM instead during programming. – Lundin Apr 01 '19 at 13:42

0 Answers0