Introduction to Micro-controllers. Anurag Dwivedi

Similar documents
Layman definition: Gadgets and devices Technical definition: Self-controlled devices Usually, such systems consist of I/O (input/output) devices such

Robosoft Systems in association with JNCE presents. Swarm Robotics

C Programming in Atmel Studio 7 Step by Step Tutorial

An FTDI connection: The ATtiny microcontrollers don t have a hardware UART External Crystal header pins for an optional crystal

Objectives. I/O Ports in AVR. Topics. ATmega16/mega32 pinout. AVR pin out The structure of I/O pins I/O programming Bit manipulating 22/09/2017

AVR Board Setup General Purpose Digital Output

Using Arduino Boards in Atmel Studio 7

EE 109 Unit 4. Microcontrollers (Arduino) Overview

Software debouncing of buttons

Programming Microcontroller Assembly and C

Introduction. Unit 4. Numbers in Other Bases in C/C++ BIT FIDDLING. Microcontrollers (Arduino) Overview Digital I/O

COMP2121 Experiment 4

CHAPTER 6 CONCLUSION AND SCOPE FOR FUTURE WORK

Designing and Building A Cable Tester. Elliot Maude

Page 1 of 7. Samtron/Samsung 20S204DA2

WEATHER STATION WITH SERIAL COMMUNICATION

Module 2: Introduction to AVR ATmega 32 Architecture

Lab Course Microcontroller Programming

Mechatronics and Measurement. Lecturer:Dung-An Wang Lecture 6

// sets the position of cursor in row and column

Embedded programming, AVR intro

ATMEL PIN MACROS. Here is an example on Stack Overflow. As a concrete example, we might consider


ECE 353 Lab 4. General MIDI Explorer. Professor Daniel Holcomb Fall 2015

INTERFACING HARDWARE WITH MICROCONTROLLER

Embedded Systems. Introduction. The C Language. Introduction. Why C instead ASM. Introduction to C Embedded Programming language

CHAPTER 1 - World of microcontrollers

COMP2121: Microprocessors and Interfacing. I/O Devices (I)

Laboratory 1 Introduction to the Arduino boards

2. Tutorial ESC Programming myavr MK2 USB UFO Doctor, June 5 rd, 2010

CN310 Microprocessor Systems Design

SquareWear Programming Reference 1.0 Oct 10, 2012

Tic-Tac-Toe Digital and Analogue Projects, LTH

IAS0430 MICROPROCESSOR SYSTEMS

ELCT708 MicroLab Session #1 Introduction to Embedded Systems and Microcontrollers. Eng. Salma Hesham

Introduction to Embedded Systems

Review on Lecture-1. ICT 6641: Advanced Embedded System. Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming

// filename pwm.c // ATtiny84 (14 pin DIP)

#include <avr/io.h> #include <avr/interrupt.h> #include <util/delay.h> #include <string.h> #include <stdlib.h> #include "lcd.c"

Debugging embedded HW/SW systems differs greatly from debugging software or hardware alone. Key steps to debugging: 1

User s Manual of Board Micro Controller ET-EASY168 STAMP ET-EASY168 STAMP. Picture displays structure of Board ET-EASY168 STAMP.

USER MANUAL ARDUINO I/O EXPANSION SHIELD

Programming Microcontroller

Lecture 2. Introduction to Microcontrollers

AVR PCD8544 DRIVER DOCUMENTATION

How to use RFpro in Packet Mode

Character Based LCD Module Interface.

Embedded Systems Programming. ETEE 3285 Topic HW3: Coding, Compiling, Simulating

Lecture (04) PIC 16F84A programming I

Microcontroller basics

RC CAR. Shahadat Hussain Parvez. Jubair Hossain. Tahmid Hassan Talukdar. 12-Apr-12

BV4218. I2C-LCD & Keypad. Product specification. December 2008 V0.a. ByVac 2006 ByVac Page 1 of 9

COMP2121: Microprocessors and Interfacing. Introduction to Microprocessors

MICROPROCESSORS A (17.383) Fall Lecture Outline

Distributed Real- Time Control Systems

The naked computer. The naked computer. Separate bus architecture. Real-time Systems SMD138

Atmel Startup 3: Binky One PORT, PIN, DDR and LED

Buses and Parallel Input/Output

Basic Components of Digital Computer

AGH University of Science and Technology Cracow Department of Electronics

Assembly Programming in Atmel Studio 7 Step by Step Tutorial

MICROPROCESSORS A (17.383) Fall Lecture Outline

Introduction to the MC9S12 Hardware Subsystems

CHW 469 : Embedded Systems

AVR Programming in C. Topic/Week 9 ISMAIL FKE UTM


EMBEDDED HARDWARE DESIGN. Tutorial Interfacing LCD with Microcontroller /I

4. Application Programming

INDUSTRIAL TRAINING:6 MONTHS PROGRAM TEVATRON TECHNOLOGIES PVT LTD

AVR 40 Pin Rapid Robot controller board

Microcontrollers. Outline. Class 1: Serial and Digital I/O. March 7, Quick Tour of the Board. Pins, Ports, and Their Registers

ET-BASE AVR ATmega64/128

Embedded Systems and Software

Microprocessors And Microcontrollers (Practical)

How2Use DT-AVR ATMEGA168 BMS. By: IE Team. Picture 1 The layout of DT-AVR ATMEGA168 BMS

- Open-source and open-hardware modular robotic platform specially created for educational purposes.

Introduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3

#include <avr/io.h> #include <avr/interrupt.h> #define F_CPU UL // 8 MHz.h> #include <util/delay.h>

Overview. The C programming model. The C programming model. The C programming model. The C programming model 1/23/2009. Real-time Systems D0003E

CONTENTS. dspicpro4 KEY FEATURES 4 CONNECTING THE SYSTEM 5 INTRODUCTION 6

Introduction to Microcontrollers

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...

Explanation of PIC 16F84A processor data sheet Part 1: overview of the basics

AGH University of Science and Technology Cracow Department of Electronics

AN1745. Interfacing the HC705C8A to an LCD Module By Mark Glenewinkel Consumer Systems Group Austin, Texas. Introduction

Final Design Report. Team Name: No Rest for the Weary

Lecture (03) PIC16F84 (2)

68HC12 Training Lab Student Exercise Book

AVR Simulation with the ATMEL AVR Studio 4 Updated: 8/3/2005

ECE 4510/5530 Microcontroller Applications Week 7

,$5$SSOLFDWLRQ1RWH$95 (IILFLHQWSURJUDPPLQJRI$WPHO V $95 PLFURFRQWUROOHUV

Digital Input and Output

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet... 4

Lab 2: Basic Assembly Programming and Debugging using AVR Studio. Due: December 13, 2011

Submit this lab and the extended learning (optional) to TEACH by Monday at 11:59pm. You must get checked off by a TA by the beginning of lab 7.

Physics 335 Intro to MicroControllers and the PIC Microcontroller

ATMega128 Rapid Robot Controller Board [RKI-1148]

Comparison of C and Assembly How to compile a C program using CodeWarrior

Embedded Systems and Software

Accelerometer board. EB068

Transcription:

Introduction to Micro-controllers Anurag Dwivedi

Lecture Structure Things to be covered today.. What is a micro-controller? What are the basic features of a microcontroller? How to input and output from a microcontroller? How to program a micro-controller? Demonstration : Led Blinking. Interfacing Character LCD with Microcontroller. Demonstration : CLCD Interfacing.

Embedded Systems Layman definition: Gadgets and devices Technical definition: Self-controlled devices Usually, such systems consist of I/O (input/output) devices such as LCDs, keypads, etc. and other devices like EEPROM (for storing data) connected to a central controlling device.

Example : MP3 Player

The Micro-controller Why micro? Larger controllers are available too: processors that run computers are an example. A microcontroller is essentially a minicomputer inside a single IC.

Micro-controllers Multiple microcontrollers available in the market. Vendors include Atmel, Intel, ARM, Cypress, etc. We will use Atmel ATmega microcontrollers because they are cheap, easy to use and powerful.

Atmega 16 40 pin IC. 32 pins for I/O. 8 pins reserved. I/O pins divided into 4 groups of 8 pins, called ports. Ports labeled as A, B, C and D.

How does a micro-controller work Just like a computer, a microcontroller executes a program. The task to be performed is written in a while loop, and the micro-controller performs is endlessly. The program for a microcontroller is written in C language (although other languages are possible).

Input/Output (I/0) Input / Output is via special variables called registers. Registers are actual hardware memory locations inside the μc. Their names and sizes are predefined. When we assign a value to these registers in the program, the actual value in the hardware changes. These values can be changed multiple times at any point in the program.

I/O Registers There are 3 registers that control the I/O pins: DDR, PORT and PIN. Each port has it s own registers. Hence, port A has registers DDRA, PORTA, PINA; port B has registers DDRB, PORTB, PINB; and so on. DDR, PORT and PIN serve different functions.

DDR ( Data Direction Register ) DDR decides whether the pins of a port are input pins or output pins. If the pin is input, then the voltage at that pin is undecided until an external voltage is applied. If the pin is output, then the voltage at that pin is fixed to a particular value (5V or 0).

Setting Register Values DDR is an 8 bit register. Each bit corresponds to a particular pin on the associated port. For example, the MSB on DDRA corresponds to the pin A7.

Interpretation of DDR Values If a bit on the DDR register is 0, then the corresponding pin on the associated port is set as input. Similarly, if the bit is 1, then the pin is set as output. Example: if DDRA = 0b10010110, then:

PORT Register PORT is also an 8 bit register. The bits on the PORT register correspond to the pins of the associated port in the same manner as in the case of the DDR register. PORT is used to set the output value. If the pin is set as output, then a PORT value of 1 will set voltage at that pin to 5V. If PORT value is 0, then voltage is set to 0V.

Pull Up / Pull Down What if we try to set the PORT value of a pin that is configured as input? A separate purpose is served: that of pull up or pull down. When an input pin is connected by a wire to some specific voltage, it s voltage also becomes that same value.

Pull Up/ Pull Down But, when the input pin is left free, it s voltage value is undecided. This is bad. To prevent this, a default value is assigned. This value can be either 5V or 0, and is of consequence only when the pin is unconnected. The PORT value becomes this default value. If default value is 0, then pin is pulled down. If it is 5V, then it is pulled up.

Pin Register PIN is a register whose value can be read, but cannot be changed inside the program. It gives the value of the actual voltage at a particular pin. 5V corresponds to 1, and 0 corresponds to 0.

Summary

Some C concepts is bitwise OR. Eg. 10100111 11000101 = 11100111 & is bitwise AND. Eg. 10100111 & 11000101 = 10000101 ~ is bitwise NOT. Eg. ~10100110 = 01011001 << is shift left. >> is shift right.

Simplest C program for a micro-controller int main(){ return 0; }

Example Program 1 #include <avr/io.h> int main(){ DDRA = 0b11111111; // or 255 or 0xFF while(1){ PORTA = PINC; } return 0; }

Example Program 2 #include <avr/io.h> #include <util/delay.h> int main(){ DDRA = 0xFF; while(1){ PORTA = 0xAA; _delay_ms(1000); PORTA = 0x55; _delay_ms(1000); } return 0; }