AnsweredAssumed Answered

FRDM-KL03Z Reading WriteOnce Special area of 0 IFR fails with reset and LOCKUP bit set in SRS1.

Question asked by marcinmazur on May 11, 2016

FRDM-KL03Z Reading WriteOnce Special area of 0 IFR fails with reset and LOCKUP bit set in SRS1.

 

Hello.

 

I'm using FRDM-KL03Z board and i want to read 64 special bytes (WriteOnce area) located in 0 IFR area.

 

Following reference maual i wrote code, but it seems to be working very strange.

If I run it under debugger, step by step - everything seems to be ok, but, when it is free running it fails with reset and LOCKUP bit set in SRS1 register (catched in debugger).

commenting line 23 results at program is running fine (but is ofcourse not doing anything).

 

Here is my code:

main.c

#include "MKL03Z4.h"  static unsigned char ifr[64]; int main(void) { #define RDONCE 0x41    //check and evt. wait for flash command to ready.   while ((FTFA->FSTAT & FTFA_FSTAT_CCIF_MASK)  == 0) {   // busy...   __asm__ volatile ("nop");   }    //reset errors   FTFA->FSTAT = FTFA_FSTAT_FPVIOL_MASK | FTFA_FSTAT_ACCERR_MASK | FTFA_FSTAT_RDCOLERR_MASK; // clear errors   for (unsigned char i=0; i < 0x10; i++) {    FTFA->FCCOB0=RDONCE;   FTFA->FCCOB1=i;   //FTFA->FCNFG |= FTFA_FCNFG_RDCOLLIE_MASK; //read collision detection    //start command   FTFA->FSTAT = FTFA_FSTAT_CCIF_MASK;    while ((FTFA->FSTAT & FTFA_FSTAT_CCIF_MASK)  == 0) {   // wait for finish ...   __asm__ volatile ("nop");   }    if ((FTFA->FSTAT & FTFA_FSTAT_FPVIOL_MASK ) || (FTFA->FSTAT & FTFA_FSTAT_ACCERR_MASK )){ // debug("x",0);   FTFA->FSTAT = FTFA_FSTAT_FPVIOL_MASK | FTFA_FSTAT_ACCERR_MASK | FTFA_FSTAT_RDCOLERR_MASK; // clear errors   } else { // debug(".",0);   }    ifr[i*4]=FTFA->FCCOB4;   ifr[i*4+1]=FTFA->FCCOB5;   ifr[i*4+2]=FTFA->FCCOB6;   ifr[i*4+3]=FTFA->FCCOB7;   }    while (1) {   __asm__ volatile ("nop");   }   return 0; }

 

I'am looking for any help, what i'am doing wrong?

Please check attachment, its simple project in KDS3 with this code.

Original Attachment has been moved to: testt.zip

Outcomes