E02 EEPROM Questions

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

E02 EEPROM Questions

2,767 Views
d_
Contributor I

Hi,

I'm getting ready to use EEPROM on the MKE02Z64VLC2.  I implemented some of the EEPROM example program and have it running.  Clock init is OK, I can erase, write and read.  There is a weird symptom though.  I know there are 256 bytes of 128 sectors of 2 bytes each.  But I cannot erase 128 sectors.  It seems that if I go over 64 the debugger "loses connection" with the ARM and terminates the session.  Any ideas?

The next question is, I've read through the documentation and see nothing about external flash burning tools.  Can the EEPROM be burned directly through external tools?  Can anyone point me to documentation?

Thanks,

Dave

0 Kudos
24 Replies

1,810 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Dave,

        Thank you for you question in our community!

1:

I use our EEPROM_demo on our FRDM-KE02z, it can earse all the 128 sectors when I am debugging. How did you debug it? Step by step or set point? I set a breakpoint after the code which do all sectors earse. Just like the following, 

    for( i=0;i<128;i++)

    {

EEPROM_EraseSector( i*2 + EEPROM_START_ADDRESS);

    }

        for(i=0;i<512;i++)

    {

        u8DataBuff[i] = (uint8_t)i;  // put a breakpoint here

}

my code will stop on the breakpoint, it means I can earse all the 128 sectors.

2:

We don’t have the tool to just program EEPROM on E02 except for downloading the program to flash combine with debug tools, eg opensda, jlink.

Wish my answer is useful to you!

If you still have quesiton , please contact me!

Best regards,

Jingjing

0 Kudos

1,810 Views
d_
Contributor I

Hi Jingjing,

Thanks for the reply.

I tried it again but putting a breakpoint at the erase line, then running to the breakpoint.  It erases all 128 sectors.  But when I run in real time, the debugger loses connection.

So then I tried first a short delay between erases.  That also failed.  But next I did a longer delay between erases, and that passed.

The difference between your FRDM code and my code is my oscillator is 20 MHz, not 10 MHz.  But, I am calling FLASH_Init() with 20,000,000 so the flash clock should be right.  But apparently I'm violating a timing spec somewhere.  Can you identify that?

I've used both opensda and multilink, but where in CW would I select to program EEPROM rather than flash, and how would I specify what data to write in there?

New questions are:

Do I need to use specific EEPROM read commands to detect bit errors (rather than just reading memory)?

The reference manual talks about 1 and 2 bit detection, but in the FERSTAT register it does not say that 1 bit correction is performed. Is it automatically performed when the data is read?

Is the double bit detection just double bit, or greater than 1 bit? i.e., can multiple bit errors > 2 bits be missed by the ECC?

Thanks again,

Dave

0 Kudos

1,810 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Dave,

     About your second question, program EEPROM.

     I mean that just use the code(eg, our eeprom_demo) to write the data which you are needed to your EEPROM.

     When you want to download new code, just don't do mass earse, your EEPROM data will still in your chip.

     New questions, I need to communicate with our AE, and I will reply you as soon as possible.!

Best regards,

Jingjing

0 Kudos

1,810 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Dave,

   I have some points to make sure about your first question.

   Is your chip's full name is KE02Z64VQH2? You said you are using 20Mhz external oscillator, did you just calling FLASH_Init() with 20,000,000, and nothing else modified in the sample code?

Did you change the EXT_CLK_FREQ_KHZ to 20000 in the ke02_config.h ? Just like following:

   

#define EXT_CLK_FREQ_KHZ    20000   /* in KHz */

This is very important,  if you don't do this,  I think your core frequece and bus frequence will have some problems.

Because if you still use 10000Khz, your ICS_C1_RDIV(3), it is your RDIV is 256, not 512(ICS_C1_RDIV(4)), then your ICSFLLCLK will be 80Mhz, your FLL clock lock will have problem.

void ICS_SetClkDivider(uint32_t u32ClkFreqKHz)

{

   

    switch(u32ClkFreqKHz)

    {

        case 8000L:

        case 10000L:

            /* 8MHz or 10MHz */

            ICS->C1 = (ICS->C1 & ~(ICS_C1_RDIV_MASK)) | ICS_C1_RDIV(3);    /* now the divided frequency is 8000/256 = 31.25K */

                                                                        /* now the divided frequency is 10000/256 = 39.0625K */

            break;

        case 4000L:

            /* 4MHz */

            ICS->C1 = (ICS->C1 & ~(ICS_C1_RDIV_MASK)) | ICS_C1_RDIV(2);    /* now the divided frequency is 4000/128 = 31.25K */

            break;

        case 16000L:

            /* 16MHz */

            ICS->C1 = (ICS->C1 & ~(ICS_C1_RDIV_MASK)) | ICS_C1_RDIV(4);    /* now the divided frequency is 16000/512 = 31.25K */

            break;

        case 20000L:

            /* 20MHz */

            ICS->C1 = (ICS->C1 & ~(ICS_C1_RDIV_MASK)) | ICS_C1_RDIV(4);     /* now the divided frequency is 20000/512 = 39.0625K */

            break;

        case 32L:

            /* 32KHz */

            ICS->C1  &= ~(ICS_C1_RDIV_MASK);

            break;

        default:

            break;

    }

}

you can test your bus clock to make sure whether your clock is correct,  from our reference manual, PTH2 is the bus out pin. You can use this pin to test.

pastedImage_4.png

pastedImage_1.png

Enable the bus out pin ,just add this code :

SIM->SOPT |=(1<<19);
SIM->SOPT &=0xf8ffff;

If you don't change the EXT_CLK_FREQ_KHZ to 20000, please change it, and test your eeprom again!

Wish it helps you!

Jingjing

0 Kudos

1,810 Views
d_
Contributor I

Hi Jinging,

The chip is MKE02Z64VLC2.

Yes, I did modify ke02_config.h so that EXT_CLK_FREQ_KHZ is 20000,

resulting in BUS_CLK_HZ = 20000000.

This configuration results in ICS->C1 = 0x20 (after setting external

clock) and FCLKDIV = 0x93. I believe both of those are correct.

I'm using the 32 pin device, so I don't have the option of routing

the bus clock to an external pin.

Thanks,

Dave

0 Kudos

1,810 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Dave,

       Sorry for my later reply because of our weekends.

      Your register is correct for your configuration.

       Now, we need to check your real bus clock, if you don't have the busout pin, you can use RTCO pin to check your bus clock, just need to add some RTC code, and test a pin wave.

pastedImage_1.png

Th is use RTC to test your busclock,  if your busclock is 20Mhz, your PTC5 pin will have a 10Khz wave, just like follows:

pastedImage_2.png

So, could you please add the code, and test the PTC5 pin's wave, and give it to me?

By the way, you said when you run in real time, your debug will lost, Did you mean just not set breakpoint, and click this button pastedImage_3.png in CW?

If you set break point like following, your debug will still be lost?

pastedImage_4.png

Please test your bus clock with RTC at first.

Other questions , I will reply you in your SR.

Waiting for your new test result.

Best Regards,

Jingjing

0 Kudos

1,810 Views
d_
Contributor I

Hi Jingjing,

Thanks for the help.

Setting the RTC to use the bus clock with a modulo of 9 gives me

exactly 10KHz on PTC5. So that confirms that my bus clock is 20

MHz. We've confirmed before that the flash configuration for a 20

MHz bus clock is correct. (Page 484 of the reference manual does not

say what the prescalers are for x2 and x3. How does this work with

table 28-5?)

With respect to the debug session being terminated, I got tired of

the popup so I checked the "don't show this again" box. Can you tell

me how to re-enable that so the popup occurs again?

What happens is I tell the debugger to run by clicking on the run

button (the green right arrow picture you show in your

response). The debugger runs for a short time then exits. I don't

have the popup anymore, but the debug and console windows are shown

in the attached picture.

The second picture shows my test code. If I set a breakpoint at line

20 (with the for loop delay commented out), then keep running to the

breakpoint, the long delay for each breakpoint is long enough to make

it work. If I run without the breakpoint (again with the for loop

commented out), I get the session terminated problem. If I put the

for loop delay in by uncommenting it, then everything works fine

again with the long delay. This is why I believe there is a timing

issue somewhere with the EEPROM.

Thanks,

Dave

0 Kudos

1,810 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Dave,

     If you also have the 10Khz on the PTC5, your bus clock is really 20Mhz, that is correct, about the RTC working question, after this problem is solved, I will discuss with you about it , your RTC is correct.

    From your picture, I find it is not our KE02 driver project, so could you give me your project, I will help you to check it, I need to make sure whether it caused by your software. I will use your project, and change my oscillator to 20Mhz, then test it to see whether the project works OK or not.

     Waiting for your project.

Best regards,

Jingjing

0 Kudos

1,810 Views
d_
Contributor I

Hi Jingjing,

I'm attaching a small project which re-creates the problem. It is

running on my KE02 with a 20 MHz crystal.

In main.c, if you comment out the for loop (delay) in line 34, the

debugger terminates unexpectedly. If you leave the delay in,

everything works fine.

The output pin toggled by the RTC is running at 10 KHz.

Please answer the following questions:

Page 484 of the reference manual for RTC does not say what the

prescalers are for x2 and x3. How does this work with table

28-5? (I haven't figured out how you get to 10 KHz output from the

20 MHz bus clock.)

My new project now has the popup when the debugger terminates. I've

turned this off in my main project but would like to turn it on

again. How do I do this?

Thanks,

Dave

0 Kudos

1,809 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Dave,

      About the debug question, I need to find a 20Mhz crystal and test it, it may have delay, I will reply you as soon as possible.

But use your project, I change the code to 10Mhz, the code works fine.

    Now I reply your RTC quesiton at first.

  

pastedImage_2.png

Our configure RTCLKS is 11 bus clock, RTCPS is 110, from the following picture, you get clock divider is 100, then you will get that why output is 10Khz.

pastedImage_0.png

This is how I get the 10Khz,  and you already get it, now do you understand it?

Wish it helps you!

Best regards.

Jingjing

0 Kudos

1,810 Views
d_
Contributor I

Hi Jingjing,

The dividers down from 20 MHz are obvious if you make some assumptions.  It's the assumptions that are not well defined.  But I see where my confusion is.  I did not understand that the "x0" and "x1" symbols meant that bit 1 was a don't care and only bit 0 was being used to select between the 2 divider values.  Since I didn't see a note saying bit 1 was ignored and that the x0/x1 was a bit field, I made the wrong assumption that it was a hex number.  Confusing.

OK, I think that answers everything but the debugger termination on 20 MHz.

Thanks,

Dave

0 Kudos

1,810 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Dave,

     Did you mean RTCLKS = x0, or x1 make you confusing?

   If you check the RTCLKS, you will find the RTCLKS is two bits,

00 External clock source.

01 Real-time clock source is 1 kHz (LPOCLK).

10 Internal reference clock (ICSIRCLK).

11 Bus clock.

so ,it is clear that RTCLKS=x0, x is not matter 0 or1, just care bit0.

About the debugger termination, do you have a 10 Mhz crystal? because I don't have the 20Mhz crystal, so could you check your board with 10Mhz crystal, to see whether this problem will appear again?

If it still appear, I think you should check your hardware, eg, board layout.

Best regards,

Jingjing

0 Kudos

1,810 Views
d_
Contributor I

Hi Jingjing,

Yes, I was confused by x0 and x1. I did not realize that x0 meant

either 00 or 10 and x1 meant either 01 or 11. IOW, I didn't know it

was a binary representation. Now that I do, no problems.

Thanks,

Dave

0 Kudos

1,810 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Dave,

     Really so quick reply!

    About x0,x1, please don't get confuse with it, it is just the normal knowledge, it is just the binary representation.

    If you meet the same situation, just check the according register, you will get it.

    If you still have other understanding problem, you can check it with me.

    About the debug problem, please change your board with 10Mhz crystal, and check it again.

    Waiting for your test result!
Best regards,

Jingjing

0 Kudos

1,810 Views
d_
Contributor I

Hi Jingjing,

OK, first thing this morning I tried again using my FRDM board at 10 MHz.  It worked fine.  But I had already modified this board by adding the header for the Multilink JTAG, so I decided to try that too.  And that fails.

Works on OpenSDA, fails on Multi-link.

What now?

Dave

0 Kudos

1,810 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Dave,

    Thank you for your test result!

    I tried it with multilink universal, and the debugger will lost communication too.

   I think this is the multilink's problem, and multilink is not our product, please ignore this problem when you write the eeprom code, because our KE chip is working ok, don't add the delay code in the erase function, debug is not the real running,if you want to debug, you can just use the opensda to debug it.

   If you want to know why multillink has this problem, you need to contact with the PEmicro, the link is :http://www.pemicro.com

   Wish my answer helps you!

Best regards,

Jingjing

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,810 Views
d_
Contributor I

Thanks for the help Jingjing. I have opened a ticket with P&E.

Regards,

Dave

0 Kudos

1,810 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Dave,

      If PE give you the answer how to solve the multlink's problem, please share your answer on our community, then other people can refer to it.

      If they don't have solution, you still can use the opensda to download the flash.

Best regard,

Jingjing

0 Kudos

1,810 Views
d_
Contributor I

P&E has had this open for quite some time.  I followed up with an email, but the tech support agent, Johnny, never replied.

I do not know if P&E has been able to recreate the problem.  I assume they have no solution.

Dave

0 Kudos

1,810 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Dave,

    If they have no solution, you can download your code to your flash directly instead of debug test.

  Another way, you can use other debug tool, eg, opensda, or Jlink.

Wish it helps you!

Best regards,

Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos