1 / 12

Using the AVR UART

Using the AVR UART. Overview. How do I know what to do? What do I do? Setup the Wunderboard Setup the Host computer Setup the #define statements. How do I know what to do?. The first step is to read even if it does not make sense the first time Second is to ask

ceana
Télécharger la présentation

Using the AVR UART

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using the AVR UART

  2. Overview • How do I know what to do? • What do I do? • Setup the Wunderboard • Setup the Host computer • Setup the #define statements

  3. How do I know what to do? • The first step is to read even if it does not make sense the first time • Second is to ask • Third is to hope and pray ;)

  4. What do I do? • When working with lots of 'unknowns' limit yourself to one unknown at a time. • Don't try new software on a PC and a microcontroller while also using new hardware. • Limit your uncertainty

  5. Setup the Wunderboard • The Wunderboard code needs three functions • unsigned char InitializeUART () • unsigned char SendByteUART () • unsigned char SendStringUART()

  6. unsigned char InitializeUART () • This function setup the Wunderboard to transmit serial data • You need to set the values of the UBRRn, UCSRnA, UCSRnB, and UCSRnC registers • Make sure you read the datasheet, section 18.10 thoroughly

  7. unsigned char SendByteUART () • This function should check if the UART is ready to send a new byte. • If it is, it should send other wise it should exit immediately • Don't forget your return value!

  8. unsigned char SendStringUART() • This function should try to send a string of characters by repeatedly calling the SendByteUART() function • If the first character it tries to send fails, the function should exit immediately • Otherwise the function blocks until the entire string is sent.

  9. Setup the Host computer • To see the serial data being sent from the Wunderboard, you need to setup a 'terminal' program • Make sure you use the same settings as your Wunderboard

  10. Setup the #define statements • Finally once you know your code works, encase the UART material in #ifdef preprocessor statements • This lets you enable and disable the UART with a single line.

  11. Prelab Walk-Through • Lets go through the prelab together

  12. Parting Thoughts • Look at return values and write functions that use them • Read everything • Ask for help

More Related