Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
abbanerjeersm opened this issue Jun 8, 2015 · 4 comments
Open

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

abbanerjeersm opened this issue Jun 8, 2015 · 4 comments

Comments

@abbanerjeersm
Copy link

No description provided.

@abbanerjeersm abbanerjeersm changed the title Datasheets and Mn Datasheets and Manuals Jun 8, 2015
@abbanerjeersm
Copy link
Author

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 abbanerjeersm changed the title Datasheets and Manuals Main.c does cli() but not sei() Jun 8, 2015
@ComputerNerd
Copy link
Owner

My code never uses interrupts.

@abbanerjeersm
Copy link
Author

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

@abbanerjeersm
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants