How to delete the previous program on the MCU ?

Hello

I've uploaded a program on the MCU, but i want to upload another totally different program on the MCU, how can i delete the previous one?

Thanks a lot. :)

You don't need to delete the previous one. Uploading over-writes an existing application.

Just upload a new one, it can only hold and run 1 program at once, the old one will be deleted when you upload the new one.

thanks :)

Problem Solved !
Thanks everyone :slight_smile:

is there any difference between :

1) bootloaded MCU (upload again serially) 2) upload again by external programmer

do they both erase the previous program?

1) bootloaded MCU (upload again serially)

Overwrites the previous program.

2) upload again by external programmer

Typically overwrites the previous program. It depends on how the external programmer is used.

Doesn't uploading via an external programmer also overwrite the bootloader? This happens when I use Studio4 to upload a program requiring the bootloader to be reloaded before using in the Arduino again.

ken H.

Doesn't uploading via an external programmer also overwrite the bootloader?

I believe the program can be positioned in memory so as to not overwrite the bootloader. An external programmer should give very fine control over what gets put where. But you certainly should try this first!

The thing to remember is that with program memory, you can only change (program) a 1 bit to a 0 bit, but not a 0 bit to a 1 bit. So the act of reloading always involves first 'erasing' program memory so that all bits are set to 1 and then programing the new code into it.

The main difference in loading via bootloader Vs external hardware programmer is that the bootloader code doesn't get erased when the chip is erased because of fuse bits set to 'protect' that portion of program memory.

At least that is how I've come to understand all the various explanations.

Lefty