This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

STATUS_FAIL_PROGRAM when using flash `API - TMS320F28335

I am using the Flash_Program() function provided in the flash api to write a 64-bit value to the OTP.

Initially I had a problem that the device is reset every time I attempt to write to OTP. I went through the forum and found that interrupts are serviced in the non-critical time periods of the flash API functions. During this time the flash and OTP remain inaccessible which could cause the device to reset.

So, I am currently disabling all the maskable interrupts like this:

asm(" setc INTM")          // DINT

Status = Flash_Program(Flash_ptr, buffer, Length, &FlashStatus);

asm(" clrc INTM")          // EINT

But now I get Status =  STATUS_FAIL_PROGRAM, which means the OTP is not programmed. When I remove the DINT and EINT I can see that part of the value is written to OTP before being interrupted and reset. I am unable to figure out what could cause this behavior. 

Thanks in advance!