Microcontroller basics

Similar documents
Microcontroller basics

AVR XMEGA Product Line Introduction AVR XMEGA TM. Product Introduction.

AVR XMEGA TM. A New Reference for 8/16-bit Microcontrollers. Ingar Fredriksen AVR Product Marketing Director

Network Embedded Systems Sensor Networks Fall Hardware. Marcus Chang,

Arduino Uno R3 INTRODUCTION

MICROPROCESSOR BASED SYSTEM DESIGN

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

ATmega128. Introduction

To be familiar with the USART (RS-232) protocol. To be familiar with one type of internal storage system in PIC (EEPROM).

Serial Communications

ARDUINO MEGA INTRODUCTION

Embedded Systems and Software. Serial Interconnect Buses I 2 C (SMB) and SPI

acret Ameya Centre for Robotics & Embedded Technology Syllabus for Diploma in Embedded Systems (Total Eight Modules-4 Months -320 Hrs.

WIZTECH AUTOMATION SOLUTIONS (P) LTD., An ISO 9001:2000 and IAO certified company

8. Power Management and Sleep Modes

USER GUIDE EDBG. Description

Diploma in Embedded Systems

Serial Communications

Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform.

CN310 Microprocessor Systems Design

Embedded Systems. Software Development & Education Center. (Design & Development with Various µc)

EDBG. Description. Programmers and Debuggers USER GUIDE

Lab Course Microcontroller Programming

Embedded Systems Lab Lab 1 Introduction to Microcontrollers Eng. Dalia A. Awad

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

KNJN I2C bus development boards

Lecture 5: Computing Platforms. Asbjørn Djupdal ARM Norway, IDI NTNU 2013 TDT

Basics of UART Communication

Basic Components of Digital Computer

Product Technical Brief S3C2440X Series Rev 2.0, Oct. 2003

Embedded Systems and Software

or between microcontrollers)

Introduction to ARM LPC2148 Microcontroller

Infineon C167CR microcontroller, 256 kb external. RAM and 256 kb external (Flash) EEPROM. - Small single-board computer (SBC) with an

Introduction to Embedded System I/O Architectures

Development and research of different architectures of I 2 C bus controller. E. Vasiliev, MIET

ootbrobotics.com Electronics and Robotics LLC

The Atmel ATmega328P Microcontroller

8051 Microcontroller

19.1. Unit 19. Serial Communications

Embedded Systems and Software. Serial Communication

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

Unlocking the Potential of Your Microcontroller

An Arduino Controlled 1 Hz to 60 MHz Signal Generator

Serial Peripheral Interface. What is it? Basic SPI. Capabilities. Protocol. Pros and Cons. Uses

INTERRUPTS in microprocessor systems

Parallel Data Transfer. Suppose you need to transfer data from one HCS12 to another. How can you do this?

PIC-LCD-3310 development board Users Manual

AT-501 Cortex-A5 System On Module Product Brief

Hands on Experience with AVR32

8051 Microcontroller

Embedded programming, AVR intro

Introduction to I2C & SPI. Chapter 22

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

Product Technical Brief S3C2412 Rev 2.2, Apr. 2006

Introduction the Serial Communications Parallel Communications Parallel Communications with Handshaking Serial Communications

EECS 373 Design of Microprocessor-Based Systems

Part 1 Using Serial EEPROMs

PD215 Mechatronics. Week 3/4 Interfacing Hardware and Communication Systems

PIC Microcontroller Introduction

MSP430 Microcontroller Basics

Interconnects, Memory, GPIO

SYLLABUS UNIT - I 8086/8088 ARCHITECTURE AND INSTRUCTION SET

TEVATRON TECHNOLOGIES PVT. LTD Embedded! Robotics! IoT! VLSI Design! Projects! Technical Consultancy! Education! STEM! Software!

EECS 373 Design of Microprocessor-Based Systems

12.1. Unit 12. Exceptions & Interrupts

HZX N03 Bluetooth 4.0 Low Energy Module Datasheet

More than Compatibility

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

VORAGO VA108x0 I 2 C programming application note

Product Technical Brief S3C2413 Rev 2.2, Apr. 2006

Freescale Semiconductor, Inc.

OPERATIONAL UP TO. 300 c. Microcontrollers Memories Logic

Amarjeet Singh. January 30, 2012

G80 SoC Datasheet. Where Hardware Meets Software

Maxim > Design Support > Technical Documents > Application Notes > Microcontrollers > APP 4465

MicroProcessor. MicroProcessor. MicroProcessor. MicroProcessor

SECURE DIGITAL ACCESS SYSTEM USING IBUTTON

Clock and Fuses. Prof. Prabhat Ranjan Dhirubhai Ambani Institute of Information and Communication Technology, Gandhinagar

MCS-51 Serial Port A T 8 9 C 5 2 1

Microcontroller. BV523 32bit Microcontroller. Product specification. Jun 2011 V0.a. ByVac Page 1 of 8

KNJN I2C bus development boards

Automation Engineers AB Pvt Ltd, NOIDA Job-Oriented Course on Embedded Microcontrollers & Related Software Stack

Raspberry Pi - I/O Interfaces

Universität Dortmund. IO and Peripheral Interfaces

Robotics Training Module ABLab Solutions

PC87435 Enhanced IPMI Baseboard Management Controller

EE 308: Microcontrollers

DC6688FL32TC Super 1T 8051 Microcontroller

AVR Training Board-I. VLSI Design Lab., Konkuk Univ. LSI Design Lab

Microcontroller: CPU and Memory

VLSI Design Lab., Konkuk Univ. Yong Beom Cho LSI Design Lab

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

CSE 466 Exam 1 Winter, 2010

The Atmel ATmega168A Microcontroller

Computer Hardware Requirements for ERTSs: Microprocessors & Microcontrollers

Lab 5: EBI and ADC: Digital Voltmeter

Lab 1 Introduction to Microcontroller

Embedded Applications. COMP595EA Lecture03 Hardware Architecture

Mega128-DEVelopment Board Progressive Resources LLC 4105 Vincennes Road Indianapolis, IN (317) (317) FAX

Transcription:

FYS3240 PC-based instrumentation and microcontrollers Microcontroller basics Spring 2017 Lecture #4 Bekkeng, 30.01.2017

Lab: AVR Studio Microcontrollers can be programmed using Assembly or C language In FYS3240/4240 you have to program in C AVR studio 5 Works as editor for Assembly and C Integrated C-compiler (AVR-GCC) http://www.avrfreaks.net/

Some common uc resources Counters UART (Universal Asynchronous Receiver/Transmitter) A/D Converters (ADC) Time-multiplexing of channels is common Usually 12 or less bits per sample (8, 10, 12 bits common) SPI (Serial Peripheral Interface) I2C (at least slave function)

Digital Data Transfer SynchronousTransfer Data sent at constant rate using a shared periodic clock AsynchronousTransfer (i.e., Handshaking) Data sent upon request using handshake signals Tx and Rx still have internal clocks, they just don t share them Asynchronous transfer means that the information is not sent in predefined time slots. Data transfer can start at any given time and it is the task of the receiver to detect when a message starts and ends.

UART UART = Universal Asynchronous Receiver/Transmitter. A UART is usually an individual integrated circuit used for serial communications over a computer or peripheral device serial port. UARTs are now commonly included in microcontrollers. A dual UART, or DUART, combines two UARTs into a single chip. Many modern ICs now come with a UART that can also communicate synchronously; these devices are called USARTs (universal synchronous/asynchronous receiver/transmitter). Reset a 16 bit counter 0-7 0-15 0-15 All bits are read close to the middle of a bit value A clock 16 times faster than the bit clock is used as input to the counter

Full duplex SPI SPI = Serial Peripheral Interface Serial data link (bus) standard that operates in full duplex mode Devices communicate in master/slave mode where the master (only one master) device initiates the data frame. Multiple slave devices are allowed with individual slave select (chip select) lines. Sometimes SPI is called a "four-wire" serial bus, contrasting with three-, two-, and one-wire serial buses. Serial Clock (output from master) Serial Data In Serial Data Out ncs Bit rate usually in the MHz range Short distance communication Notes: CS = Chip Select (an enable signal) An n before a signal name, such as ncs, means that the signal is active low A bar over a signal name, such as CS, means that the signal is active low Longer cables means lower speed (because of cable capacitance etc.)

ADCs with SPI interface Many ADCs have an SPI interface Example: MCP3204 4-Channel,12-Bit A/D Converters with SPI Interface

I2C I²C = Inter-Integrated Circuit Is a multi-master serial computer bus (but only one master at a time) Uses only two bidirectional lines Data (SDA) Clock (SCL) Speed up to 3.4 Mbit/s (high speed mode) 100 kbit/s or 400 kbit/s more common? Practical communication distances are limited to a few meters The longer the cable, the lower the speed

Example: AVR XMEGA B A family of low-power, high-performance, and peripheral rich CMOS 8/16-bit microcontrollers based on the AVR enhanced RISC (reduced instruction set) architecture Two-channel DMA controller Multilevel interrupt controller Up to 53 general purpose I/O lines 16-bit real-time counter (RTC) Up to three flexible 16-bit timer/counters Up to two USARTs I2C and SMBUS compatible two wire serial interface (TWI) One full-speed USB 2.0 interface One serial peripheral interface (SPI) Up to two 8-channel, 12-bit ADCs Up to four analog comparators Watchdog timer LCD controller Internal oscillators with PLL

XMEGA uc I/O direction Output Input XMEGA PORTn.DIR PORTn.OUT PORTn.IN PORTB.DIR = 0xFF; /* All pins in PORTB configured as output*/ Note: 0x specifies a HEX number, 0b specifies a binary number

Example code for XMEGA

Interrupt-Driven Programming In interrupt-driven systems software is designed such that when a registered event, such as a timer, is received, a response is fired to respond to this event. There are two components of any interrupt-driven system: the interrupt and the interrupt handler. An interrupt is a signal that is generated by hardware, which indicates an event has occurred that should halt the currently executing program. Interrupt handlers (also referred to as interrupt service routines - ISRs) are portions of code that are registered with the processor to execute once a particular interrupt has occurred. Once the processor is aware of an interrupt, it halts the currently executing process, performs a context switch to save the state of the system, and executes the interrupt handler. Once the interrupt handler code has executed, the processor returns control to the previously running program.

Interrupts Interrupts halt normal code execution in order to go do something more important or time sensitive Used Instead of polling Can be generated internally or externally Interrupts are used e.g. for: RESET Timers Time-Critical Code Hardware signaling such as a switch pressed by the user

C programming Note: in C you can only call functions that have been defined/decleared earlier

Increment Operators i+= // in order to specify how much to increment

C programming Pointers I A pointer is an address in RAM &i get the address of the variable i *p get the content of the address location that the pointer points to

C programming Pointers II

C programming - Memory Management Allocate memory : malloc() Free used memory : free() Look out for memory leakage!