How do fill all bytes of memory with datas on S32K148

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How do fill all bytes of memory with datas on S32K148

1,026 次查看
joshfx
Contributor II

 

uint8_t data5[SIZE];

for (i = 0u; i < 5; i++)
{
data5[i] = i+1;

}

uint8_t data2[SIZE];

for (i = 0u; i < 2; i++)
{
data2[i] = i+1;
}

uint8_t data7[SIZE];

for (i = 0u; i < 7; i++)
{
data7[i] = i+1;
}

 

These are my datas. I want to write to flash memory with the most efficient way but It fills the remainder of the 8-byte section with 0s. But I want to write other data to come

ss.png

标签 (1)
0 项奖励
回复
2 回复数

1,015 次查看
joshfx
Contributor II

while(address<FLASH_END_ADDRESS){

volatile uint32_t random_num = (rand() % 3) + 1;

if(random_num == 1u){

ret = FLASH_DRV_Program(&flashSSDConfig, address, sizeof(data5), data5);
DEV_ASSERT(STATUS_SUCCESS == ret);

address += sizeof(data5);


}
else if (random_num==2u){
ret = FLASH_DRV_Program(&flashSSDConfig, address, sizeof(data2), data2);
DEV_ASSERT(STATUS_SUCCESS == ret);

address += sizeof(data2);

}
else if (random_num==3u){

ret = FLASH_DRV_Program(&flashSSDConfig, address, sizeof(data7), data7);
DEV_ASSERT(STATUS_SUCCESS == ret);

address += sizeof(data7);
}

}

Here is my writing process

0 项奖励
回复

993 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @joshfx 

in this case, it doesn't matter what the alignment is. Smallest portion of flash which can be programmed is one phrase which is 8 bytes. Cumulative programming within one phrase is not allowed, the phrase must be in fully erased state before programming.

It's mentioned also in the SDK user manual:

lukaszadrapa_0-1677230618533.png

 

If you want to avoid the alignment of char arrays to 4 bytes anyway, you can put them to structure - then there won't be those gaps.

Regards,

Lukas

0 项奖励
回复