ov7670-no-ram-arduino-uno icon indicating copy to clipboard operation
ov7670-no-ram-arduino-uno copied to clipboard

Main.c does cli() but not sei()

Open abbanerjeersm opened this issue 9 years ago • 4 comments

abbanerjeersm avatar Jun 08 '15 02:06 abbanerjeersm

Hi - can you please explain why the main.c code just uses a cli to clear interrupts but is not neccesary to use a sei() once setting up the timing registers ?

abbanerjeersm avatar Jun 08 '15 14:06 abbanerjeersm

My code never uses interrupts.

ComputerNerd avatar Jun 08 '15 18:06 ComputerNerd

So why are you clearning the interrupts with cli() ?

abbanerjeersm avatar Jun 08 '15 18:06 abbanerjeersm

Found the answer in the datasheet of Atmega 328p - page 175

For interrupt driven USART operation, the Global Interrupt Flag should be cleared (and interrupts globally disabled) when doing the initialization. Before doing a re-initialization with changed baud rate or frame format, be sure that there are no ongoing transmissions during the period the registers are changed. The TXCn Flag can be used to check that the Transmitter has completed all transfers, and the RXC Flag can be used to check that there are no unread data in the receive buffer. Note that the TXCn Flag must be cleared before each transmission (before UDRn is written) if it is used for this purpose.

abbanerjeersm avatar Jun 08 '15 19:06 abbanerjeersm