Common mistakes
Informative
Pitfalls when using the memory driver, and how to avoid them. Each maps to a rule in Mem — Requirements or an error in Errors.
Assuming a job queue. There is at most one job at a time per instance; starting another while one is pending is rejected (
MEM_DEVERR_JOB_PENDING/E_NOT_OK). Wait forMEM_JOB_FINISHEDfirst (CHI-MEM-MUST-02, CHI-MEM-MUST-03).Forgetting to poll. Jobs advance only inside
Mem_PollFunction. If you never call it, the result staysMEM_JOB_PENDINGforever (CHI-MEM-MUST-04).Unaligned address or length. The driver does no alignment or buffering — align to the device’s write page (write) or sector (erase), or the request is a development error (
MEM_DEVERR_PARAM_ADDR/MEM_DEVERR_PARAM_LENGTH; CHI-MEM-MUST-16).Passing a real pointer to
Mem_Init.configPtrMUST beNULL_PTR— the configuration is selected at build time (MEM_DEVERR_PARAM_PTR).Reading the result too late.
Mem_GetJobResultreturns the most recent job’s result; each new job overwrites it. Read or copy it before starting the next job (CHI-MEM-MUST-05).Expecting write/erase verification. The driver does not read back to confirm a write or erase (CHI-MEM-MUST-15); do your own verification if you need it.
Freeing the buffer too early. Keep the
Mem_Read/Mem_Writebuffer valid until the job leavesMEM_JOB_PENDING.