O
O
OSBoy2019-01-11 09:37:12
Atmel AVR
OSBoy, 2019-01-11 09:37:12

What happens if you try to write a value to a read-only register?

There was an error in the code where I am trying to write a value to a read-only register. Here is the piece where:

if (ADCH < 10) ADCH = 0x00; // Тут ADCH - судя по даташиту, только для чтения
OCR0A=ADCH;

Question: in this case, provided that if here returns true, will the current value of ADCH or 0 be written to the OCR0A register?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Volkov, 2019-01-12
@OSBoy

What's the point of this if block if the register is read-only? And it's read-only.
Copy the data from it into a separate variable and work with it already. This is the only true way.

E
evgeniy_lm, 2019-01-13
@evgeniy_lm

Nothing will happen. The compiler is smarter than you, it will give you a corresponding message

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question