Open abbanerjeersm opened 9 years ago
My code never uses interrupts.
So why are you clearning the interrupts with cli() ?
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.
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 ?