S32K3 Erase

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

S32K3 Erase

2,226 Views
1123HENRY
Contributor I

I am currently using the S32K312 chip.

And I want to use the C40 register to erase the chip.

So, I disabled the SPELOCK And SSPELOCK protection before using the C40asf register.

use those code:

for(i=0;i<5;i++){
(*(volatile unsigned int*)(PFLASH0_SPELOCK0+i*4)) = 0;
}
for(i=0;i<4;i++){
(*(volatile unsigned int*)(PFLASH0_SSPELOCK0+i*4)) = 0;
}

So that,SPELOCK0~SPELOCK4,SSPELOCK0~SSPELOCK3 ,It should all be zero.

The PFLASH address of the S32K312 chip is from 0x400000 to 0x5F4000.

I attempted to erase the sectors starting from 0x400000, with each sector being 8K in size.

However, when I erased the address of 0x5C0000,MCRS return a error.

c40asf->MCRS.PEP was 1, This indicates that this area has not been unlocked.

But I should have unlocked all the PFlash areas of this chip.

please help me fix it.

S32K3 

 

 

0 Kudos
Reply
7 Replies

2,209 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @1123HENRY,

Only SPELOCK[0] can be cleared by writing a 32-bit value of all zeros.

In contrast, SPELOCK[1] contains sectors that are locked by SBAF, which means those locks are not accessible to the application. 

You can only clear the locks that are available to the application.

To do this, either clear the lock bits individually, or apply a mask to selectively clear specific bits.
To verify the current lock status, read the SPELOCK registers using the register view in your debugger or IDE.

 

danielmartynek_0-1749729500681.png

 

Regards,

Daniel

0 Kudos
Reply

2,176 Views
1123HENRY
Contributor I

And Could you please tell me what the functions of the pflash0 and pflash1 registers are?

0 Kudos
Reply

2,190 Views
1123HENRY
Contributor I

I saw that the SBAF of S32K12 is from 0x5F4000 to 0x5FFFFF, but 0x5C0000 is not within this range.

1123HENRY_0-1749777666543.png

 

0 Kudos
Reply

2,142 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @1123HENRY,

Have you tried clearing the bits individually?

If you want to program the sector at 0x5C0000, clear the corresponding lock, not the whole register. The sectors locked by SBAF cannot be unlocked by the application.

 

Thanks,

BR, Daniel

 

0 Kudos
Reply

2,082 Views
1123HENRY
Contributor I
I have solved this problem. By using the "&=" operator, I unlocked the areas that do not belong to SBAF. If all the settings are set to 0, this setting operation will fail.
and Could you please tell me the functions of the pflash0 and pflash1 registers? Through the link file, I found that all the flashes are pflash, and there is no division of pflash into pflash0 and pflash1. What are the differences in the functions of these two registers?
thanks.
0 Kudos
Reply

2,068 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @1123HENRY,

Can you give me the full names of the registers you are asking about?

 

Thank you

0 Kudos
Reply

2,194 Views
1123HENRY
Contributor I
okay,thanks
0 Kudos
Reply