This repository provides an Atmel Studio solution with a bare metal code example for a basic I2C communication. This example demonstrates the basic functionality of the TWI peripheral with a basic I2C communication. The device is connected to a digital potentiometer which communicates through an I2C interface. The device sends read commands to the I2C address of the potentiometer. Two read operations are required every iteration since the potentiometer has a 12 bit resolution.
More details and code examples on the AVR128DA48 can be found at the following links:
- Atmel Studio 7.0.2397 or newer (microchip.com/mplab/avr-support/atmel-studio-7)
- AVR-Dx 1.0.18 or newer Device Pack
- AVR128DA48 Curiosity Nano (DM164151)
The AVR128DA48 Curiosity Nano Development Board is used as test platform
The following configurations must be made for this project:
TWI0:
- Configured in Master mode
- Baud rate 100000
- Using default pins (PA2 - SDA, PA3 - SCL)
- Idle bus state
- Enable
-
Open the I2C_example.atsln solution in Atmel Studio
-
Build the solution: right click on I2C_example solution and select Build
-
Select the AVR128DA48 Curiosity Nano on-board debugger in the Tool section of the project settings:
- Right click on the project and click Properties;
- Click Tool tab on the left panel, select the corresponding debugger and save the configuration (Ctrl + S)
This example represents a basic functionality of the TWI peripheral for a basic I2C communication. The device reads the value from a digital potentiometer which communicates through an I2C interface.