0
\$\begingroup\$

I am writing a program for an ATmega328P.

I have a while loop inside which I am enabling the UART receiver complete interrupt flag using the command UCSR0B |= (1 << RXCIE0).

In some conditions, the while loop will execute infinite times. Does setting the receive complete interrupt flag in the register UCSR0B have any problem with the write cycles of a register, or does a register have a maximum number of write cycles?

\$\endgroup\$
2
  • 6
    \$\begingroup\$ Hardware control registers are RAM and can be written infinitely. \$\endgroup\$ Commented Jan 14, 2022 at 10:49
  • 2
    \$\begingroup\$ One classic bug is to view code for UART or SPI with read-to-clear flags in a debugger featuring a memory map or register display. And then the debugger reads those flags and destroy them. You'll know this is the problem if the program is working fine free running, but halting when you single step through the serial driver code. \$\endgroup\$
    – Lundin
    Commented Jan 14, 2022 at 11:02

2 Answers 2

4
\$\begingroup\$

Generally registers have unlimited write cycles as they are RAM.

While this doesn't affects RXCIE0 bit, some considerations should be taken while dealing with other registers. For example some can trigger an interrupt, while other cause EEPROM writes, etc.

\$\endgroup\$
0
\$\begingroup\$

Registers are just flip-flops.

It is likely that the ATmega328P can write constantly to this register until the flash memory wears out due to old age.

\$\endgroup\$
1
  • 3
    \$\begingroup\$ That doesn't make it clear that the registers and the flash memory are separate things because it does not say that the flash memory is not flip-flops. \$\endgroup\$ Commented Jan 14, 2022 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.