S
S
Sekira2016-02-23 02:01:50
Programming
Sekira, 2016-02-23 02:01:50

Which option “wears out” the microcontroller less?

Let's say there is some variable that is incremented under certain conditions, and the rest of the time it is reset to 0.
You can write it like this:

if(num != 0)
    num = 0;

or simply
num = 0;
 

This code will be constantly executed, which option is better in terms of microcontroller wear? As I understand it, in the first variant, the number of cycles is larger and the memory occupies more, but if you do not pay attention to this, then which method is better?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Volkov, 2016-02-23
@Sekira

If your variable is in the RAM of the microcontroller, and not in non-volatile memory, then no one considers "wear and tear". There is a limit on writing to non-volatile memory. Typically 10,000 cell overwrites are guaranteed. And the amount of rewriting in RAM. Well, if you find such figures - show, it will be interesting.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question