How to relocate the expected ISR into RAM for the duration of the erase or program flash?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to relocate the expected ISR into RAM for the duration of the erase or program flash?

1,670 Views
hoangnguyenthdl
Contributor II

Hi all,

I'm programming flash for Kinetis KL16Z32 and there is a problem if an interrupt occurs during a flash erase/program operation, the Read While Write restriction will be violated if the interrupt service routine (ISR) code is located in the same flash block as the erase/program operation is occurring on. And I want to relocate the expected ISR into RAM for the duration of the erase or program time but failed. I am doing that on tool Keilc uVision5. Please help me make this on keilc 5. Thank you!

Labels (1)
0 Kudos
Reply
10 Replies

1,275 Views
hoangnguyenthdl
Contributor II

Dear Andalon,

I want the chip to have the following features:
- Module touch and can wake up from module touch with different touch pins.
- Two cores to fix disable the interruptions during write/read operations.

Can you help me find the chip that meets the above requirements? Thanks you so much!

Best regards,

Hoang Nguyen

0 Kudos
Reply

1,275 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Dear Hoang,

None of the MCUs that has two cores has the TSI (touch module). You will need to use other module/MCU for this purpose.

I'm a little worried about your application, the flash memory has a determined write cycles, if you're writing continuously the flash, the memory  life cycle will be short. As a workaround you could try writing using an array/FIFO to store the data immediately and only write the flash when you really need notifying through UART the other modules that you will not receive information in that period. This are generic suggestions but if I know more about your application maybe I could suggest other approach to this issue. Would be a problem with that?

Best Regards,
Alexis Andalon

0 Kudos
Reply

1,275 Views
hoangnguyenthdl
Contributor II

Dear Andalon,

If it is true that disable the interruptions during write/read operations, then the AN4695 (Avoiding Read While Write Errors When Developing In-Software Flash Programming Applications for Kinetis and ColdFire+ MCUs) document about how to move ISR to ram is not correct, right? Please tell me which chip line of NXP does not have to be disable the interruptions during write/read operations?
Thanks you!

Best regards,

Hoang Nguyen

0 Kudos
Reply

1,275 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Dear Hoang,

I think this will not be posible unless you have more than 1 core. If you have two cores one of this could manage the access to peripherals and the other could manage the memory access and your main applications. I will suggest to check the LPC55s6x, this MCU has a multilayer matrix to access the peripherals and the memory so I think this could be a good option.

Best Regards,
Alexis Andalon

0 Kudos
Reply

1,275 Views
hoangnguyenthdl
Contributor II

Dear Andalon,

I tried moving the expected ISR into RAM for the duration of the erase or program flash and succeeded. But writing in flash to store parameters config was wrongly written. Is there any way to check and correct the write flash wrong when there is an interrupt done in the ram? Thanks you so much.

Best regards,

Hoang Nguyen

0 Kudos
Reply

1,275 Views
cuongnguyen
Contributor II

For me, I got an issue that writing to flash was success, but read back is the previous value (before write) and  I need to reset MCU to get new value. Maybe you got similar case?

0 Kudos
Reply

1,275 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Dear hoangnguyenthdl‌,

That's why it's important to disable the interruptions during write/read operations, if one of this interrupt the write/read process this could corrupt the memory. 

In this document, section 6 explains common problems of flash programming.

Best Regards,

Alexis Andalon

0 Kudos
Reply

1,275 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Dear hoangnguyenthdl‌,

I don't think this can be done, if you interrupt an flash write operation to attend an ISR the memory could be corrupted. I think it would be better to disable the interruption until the flash operations are completed.

Best Regards,

Alexis Andalon

0 Kudos
Reply

1,275 Views
hoangnguyenthdl
Contributor II

Dear Andalon,

 

Thank you for answering my message, I am very happy.

There is no other way but to turn off all ISR interrupts, right? Because turning off all ISR interrupts will affect modules such as UART, TPM ... With UART modules will lose communication packets, this is not desirable.

 

Best regards,

Hoang Nguyen

0 Kudos
Reply

1,275 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Dear hoangnguyenthdl,

The functions that write/read to memory should be blocking, disable the interruptions until the operation is complete. Unfortunately, this is the only way to do it to ensure the correct memory operations.

Best Regards,

Alexis Andalon

0 Kudos
Reply