Skip to content

Files

Latest commit

7dd9563 · Jan 22, 2021

History

History

MCHP

One Wire Mode

This program shows how to configure the Universal Synchronous and Asynchronous Receiver and Transmitter (USART) in one wire mode. In this mode the Receive (RX) and Transmit (TX) functions use the same pin and the communication becomes half duplex. All the transmitted characters loop-back to the receive buffer and can be compared to check for bus conflicts. The applications sends the string 'Microchip.\r\n' every 500 ms through the pin used for both RX and TX.

Related Documentation

More details and code examples on the ATMEGA4809 can be found at the following links:

Software Used

Hardware Used

Setup

The ATMEGA4809 Xplained Pro Development Board is used as test platform.


The following configurations must be made for this project:

  • System clock configured for 3.33 MHz
  • Global interrupts enabled

Initialize the USART1 instance with the following configurations:

  • 9600 baud rate
  • 8 data bits
  • no parity bit
  • 1 stop bit
  • Loop back mode enabled
  • RX and TX enabled
  • Receive Interrupt enabled
Pin Configuration
PC0 RX/TX - digital input (initial configuration)

Note: The pin PC0 is configured as output when the microcontroller transmits messages, but it is configured as input in all the other cases.

Operation

  1. Connect the board to the PC.

  2. Open the atmega4809-getting-started-with-usart-studio.atsln solution in Microchip Studio.

  3. Set the One_Wire_Mode project as Start Up project. Right click on the project in the Solution Explorer tab and click Set as StartUp Project.


  1. Build the One_Wire_Mode project: right click on the atmega4809-getting-started-with-usart-studio solution and select Build Solution.


  1. Select the ATMEGA4809 Xplained Pro in the Connected Hardware Tool section of the project settings:
  • Right click on the project and click Properties;
  • Click on the Tool tab.
  • Select the ATMEGA4809 Xplained Pro (click on the SN) in the Selected debugger/programmer section, and save (CTRL + S):


  1. Program the project to the board. Then, click on the Debug tab and click Start Debugging and Break.


  1. Enable two breakpoints, as presented in the image below, and click Continue.


Demo

When sending characters, the received one works as an acknowledgement. If the received character is the same with the sent one, the transmission is successfull.

This image shows the string received in a terminal software.


Summary

This project shows how to use the USART peripheral in One-Wire mode, in which both the transmitting and the receiving will be implemented using the same pin.