Atmega8 Software I2c

Posted on  by 

A general tutorial on installing Arduino bootloader on ATmega8 AVR microcontroller and programming it using Arduino IDE.

Oct 23, 2009 A Program to demonstrate the use of I2C RTC (Real Time Clock) (DS1307). Here the DS1307 RTC Module is connected with an AVR ATmega8 MCU by I2C Serial Bus. This program reads time from the DS1307 and displays it in 16×2 LCD Module. The system also has two buttons for user interaction. The 3 buttons are. 1)MENU/Enter/Move selection.(Connected to. The Soft I2C Library for AVR. The soft I2C library for AVR comes in two files. The configuration section lets you choose the I/O lines used for SDA and SCL. You can edit the i2csoft.h file’s I/O Configuratio n area to do that. The library can be compiled for almost any AVR device like ATmega8,ATmega168,ATmega328 etc. IIC For AVR Series.Code linkhttps://github.com/skjha51/ATMEGA8-TWI. Blog Entry How to use I2C-bus on the Atmel AVR Microcontroller February 4, 2009 by rwb, under Microcontroller. I2C (read as I Squared C) bus first introduced by Philips in 1980, because of its simplicity and flexibility the I2C bus has become one of the most important microcontroller bus system used for interfacing various IC-devices with the microcontroller.

Feb 22, 2007 How it works: I2C communication, Atmega8 part I explained already in the part 1 (200502 article365) how this I2C protocol works. Let's now have a look at the software. The Atmega8 has hardware support for I2C communication. Therefore you do not actually need to implement the protocol. Instead you need to implement a state machine.

  • 71,875 views
  • 26 comments
  • 24 respects
Software

Components and supplies

Arduino UNO
×1
Microchip Technology ATmega8A-PU
×1
CH340G USB To TTL Converter
×1
16 MHz Crystal
×1
Capacitor 22 pF
×2
Resistor 10k ohm
×1
SparkFun Pushbutton switch 12mm
×1
Breadboard (generic)
×1
Jumper wires (generic)
×12
Male/Female Jumper Wires
×4

About this project

“I’ve written my code for Arduino UNO board. Is it possible to upload my sketch to an AVR microcontroller except ATmega328? I think it’s the most common question of Arduino lovers. This may have different reasons such as: Kingdoms and lords 1.1 3 mod apk.

  • Using a cheaper AVR microcontroller
  • Require an AVR microcontroller with more or even less pins than ATmega328
  • You have all kinds of AVR except ATmega328 :D

In this tutorial you will learn how to program an ATmega8 using Arduino IDE. It’s not restricted to ATmega8 only and can be generalized to other cores which are available at MCUDude’s GitHub. It consists of two parts. In part one, Installing Arduino bootloader on ATmega8 is described. Part two shows how to program an ATmega8 using Arduino IDE and a USB to TTL convertor.

Part one: Installing Arduino Bootloader

In this part, we add ATmega8 support to Arduino IDE. Then we set up the breadboard and connect ATmega8 to Arduino UNO board.

Step One: Adding ATmega8 Support to Arduino IDE Using Board Manager

There are different types of cores available on MCUDude’s GitHub repository. MiniCore is used for ATmega8 microcontroller. Supported microcontrollers in this core are:

  • ATmega8
  • ATmega48
  • ATmega88
  • ATmega168
  • ATmega328

Follow steps below to install MiniCore in your Arduino IDE.

  • In File menu, click on Preferences.
  • Now in Additional Boards Manger URLs, enter the following URL:
Atmega8 Software I2c
  • Go to Tools menu and then select Board > Boards Manager
  • In Boards Manager window, search for MiniCore and then install the latest version.

The above steps are shown graphically here: Smart music soft synth plugin download.

ATmega8 pinout is shown in the following figure.

Step Two: Programming Arduino as an ISP (In-system programming)

To burn Arduino bootloader, we need to make our Arduino UNO as an ISP. There’s a sketch named ArduinoISP in the built-in examples of Arduino IDE. Follow these steps to program your Arduino UNO as an ISP.

  • Open File > Examples > 11.ArduinoISP > ArduinoISP
  • Upload this sketch to your Arduino UNO.

Step Three: Burning Bootloader

  • Connect Arduino to ATmega8 as below.

Arduino ----------ATmega8

SCK / Pin 13 ----------SCK / PB5

Atmega8 Software I2c File

MISO / Pin 12 ----------MISO / PB4

MOSI / Pin 11 ----------MOSI / PB3

SSN / Pin 10 ----------RESET

Atmega8 Software I2c Software

  • Go to Tools > Board and select ATmega8. You can also select your clock type and frequency in Tools menu.
  • Select programmer type in Tools > Programmer: as “Arduinoas ISP”.
  • Now in Tools menu, click on the Burn Bootloader.

If the operation was successful, it says “Done burning bootloader”. Congratulations! You have done it.

Part Two: Programming ATmega8 Using Arduino IDE and a USB to TTL Convertor

Here we have an ATmega8 with Arduino bootloader. As you know, there is a USB to TTL convertor on all Arduino boards. It acts as a bridge between microcontroller and Arduino IDE. We use CH340 USB to TTL convertor module to upload the sketch to ATmega8.

Step Four: Setting up the Connections

Connect components as shown below.

CH340 ---------- ATmega8

VCC ---------- VCC

GND ---------- GND

Tx ---------- RX / PD0

Atmega8 software i2c update

Rx ---------- Tx / PD1

Step Five: Uploading the Sketch to ATmega8

Press and hold the reset pushbutton. Now click on upload in IDE. Hold the pushbutton until it says “Uploading…”on the IDE status bar. Release the button after uploading process begins. It’s because microcontroller should be in the RESET state when the uploading process starts.

Note: If the process was unsuccessful, place a 100nF capacitor at Vcc and GND of microcontroller as close as possible.

Note: Some USB to TTL convertor modules have a pin named DTR. If yours has this pin too, you can connect it to the RESET pin of ATmega8 and there’s no need to use the pushbutton to manually reset the microcontroller.

Schematics

Author

Hami Mahdavinataj
  • 1 project
  • 4 followers

Published on

November 30, 2018
Write a comment

Members who respect this project

and 18 others

See similar projects
you might like

Table of contents

Write a comment

Coments are closed