Hi,
I need some help to understand why a function don't work when called from a task context.
The function below serializes the content of a struct (memoryCopy) to a buffer, then writes it to the flash memory.
void memory_setCopy(void)
{
uint32_t result;
uint32_t size;
uint8_t buffer[4096];
/* Fill the temporary buffer with zeros */
memset(buffer,0x00,sizeof(buffer));
/* Serialize the struct */
memcpy(buffer,&memoryCopy,sizeof(memoryCopy));
/* Make sure size is a multiple of 4 */
size = (sizeof(memoryCopy) + 4) & 0xFFFFFFFFC;
/* Update the memoryCopy in the flash */
result = NVS_write(nvsHandle,0,buffer,size,NVS_WRITE_ERASE | NVS_WRITE_VALIDATE);
if(result != NVS_SOK) {
System_abort("NVS_write failed!\n");
}
}
I have tested it in the beggining of main(), before calling the tasks and BIOS initialization and it works fine.
Now, when I call it within a task, the program never returns from NVS_write().
I guess it is related with the task stack size, which is now configured to be 1024.
Can someone explain the problem here?
Tanks in advance.