AnsweredAssumed Answered

S12x Problem in accessing the flash memory

Question asked by Vishal Ranbhan on Nov 23, 2012
Latest reply on Nov 26, 2012 by Vishal Ranbhan

Hi, I am having a little issue in accessing the flash memory on the S12X module. My requirement is to compute md5 on flash memory of the s12xd256 module. So my idea was to start reading all the locations, store them in a temporary buffer. And once the buffer is full, compute md5 on them and clear the contents of the buffer. I have implemented a very similar function on the s12 module which works flawlessly, but in S12x, the moment my device tries to access the flash memory, it restarts. I am attaching the snippet below.

 

Md5.SubpageSize = 16384/128;

if(page<32)

{

if((subpage*Md5.SubpageSize)<16384)

{

old_PPAGE = PPAGE;

PPAGE = 0xE0 + page;

 

for(j=0; j<g_Md5.SubpageSize; j+=64)

{

for(k=0; k<32; ++k)    // just copy flash location ro RAM buffer

{

flash_buf[k] = *(word*)(0x8000+(subpage*g_Md5.SubpageSize)+j+(k*2));     /* 'word flash_buf[32]' is a temp buffer */

}

 

block_ptr = (byte*) &flash_buf[0];

MD5Update(&context, block_ptr, 64);

}

PPAGE = old_PPAGE;

++subpage;

}

else

{

if (page == 7){

page = 23;        /* Skip to page 23, since page 8-23 are not used*/

}

subpage = 0;

++page;

}

}

 

Thanks.


Outcomes