9/25/10

EEL 3923C JD/ Module 4 – Introduction to Ryan Nuzzaci Fall 2010

Introduction to Microcontrollers

A is a small, special purpose chip used in designs. It has an internal bus with in built memory and peripherals whereas a does not.

Common uses: • Digital assistants (PDAs), • MP3 players • Mobile phones • Videogame consoles • Digital cameras • DVD players • GPS receivers • Computer peripherals • Household appliances

EEL 3923C, Fall 2010, T. Nishida 2

1 9/25/10

Microcontroller Components

Common integrated peripherals:

• Internal oscillator • • External and internal interrupts • Analogue comparator • Analog-to-digital converter (ADC or A/D) • Serial interfaces • EEPROM

EEL 3923C, Fall 2010, T. Nishida 3

Oscillator

The oscillator is used as a clock source for the CPU and the control unit. There is usually an internal, built-in oscillator, but an external crystal oscillator may also be used (usually to increase clock rate).

EEL 3923C, Fall 2010, T. Nishida 4

2 9/25/10

Interrupts An interrupt is a process or a signal that stops a microprocessor from what it is doing so that something else can happen. When an interrupt fires, the processor stops the execution of the program, jumps to the place in memory that is reserved for the interrupt procedure, executes the procedure then returns back to the program and continues to execute. An interrupt can occur from an internal (timers) or external source (compare or capture).

EEL 3923C, Fall 2010, T. Nishida 5

Timers A timer is basically a counter unit that count the periods of the oscillator. The counter will have a particular size (i.e. 4-bit, 8-bit, 16-bit) which sets the count limit (i.e. 24, 28, 216). If turned on, the counter will fire an overflow interrupt when it reaches the limit.

Ref: http://electricly.com/category/schematic-diagram/page/5/ EEL 3923C, Fall 2010, T. Nishida 6

3 9/25/10

Input Capture and Output Compare Input capture allows the microcontroller to detect when an input pin reaches a certain voltage reference. A flag is set and/or an interrupt is fired when the detection is made. Uses: • Detect an external trigger or pulse • Calculate external signal frequency • Capture serial signal

Output compare allows the microcontroller to trigger an output pin based on a timer value. Uses: • Generate a trigger for another device • Generate a serial output signal • General a clock signal

EEL 3923C, Fall 2010, T. Nishida 7

Analog-to-Digital Converter

The analog-to-digital converter (ADC) converts an analog input voltage to a digital number that is proportional to the magnitude of the voltage. This process is known as sampling and is used to create a digital (discretized) representation of the continuous input signal. The opposite process of converting a discrete value into a (DC) voltage level can be done with a digital-to-analog converter (DAC). Both will be discussed in a future lecture.

EEL 3923C, Fall 2010, T. Nishida 8

4 9/25/10

Serial Interface Most microcontrollers will have a serial port that lets you communicate with other IC devices. The two most commonly used standard serial protocols are I2C (Inter IC communication) and SPI (Serial Peripheral Interface). A process known as ‘Bit Banging’ can also be implemented through software for serial communication over any of the uC’s I/O ports. Both methods will be explained in a future lecture.

Devices: • ADCs or DACs • Digital potentiometers • Wireless transceivers (ZigBee) • RFID Readers • FTDI (USB interfacing)

EEL 3923C, Fall 2010, T. Nishida 9

Memory

There are three types of memory found on microcontrollers:

Flash: Non-volatile memory where all of the program code is stored. RAM: Volatile memory where variables and intermediate data are stored during runtime. EEPROM: Non-volatile, Electrically Erasable and Programmable ROM is used to store data that must be saved between power up and power down (slower read/write speeds).

EEL 3923C, Fall 2010, T. Nishida 10

5 9/25/10

Block Diagram

Ref: http://www.mytutorialcafe.com/Microcontroller%20Memory%20Organization.htm EEL 3923C, Fall 2010, T. Nishida 11

Project Implementation 1. Define the project o Turn idea/concept into reality o Define project goals 2. Design and build the circuits o Choose a uC chip. (See uC assignments on slide 3.) In general, select uC based on cost, performance, as well as: •Storage • Speed • Peripherals • Available tools and documentation 3. Write the control program o Choose a • Language (high level/low level) 4. Test and debug o Simulators o (JTAG) EEL 3923C, Fall 2010, T. Nishida 12

6 9/25/10

References

Slide 8: http://electricly.com/category/schematic-diagram/page/5/

Slide 13: http://www.mytutorialcafe.com/Microcontroller%20Memory%20Organization.htm

EEL 3923C, Fall 2010, T. Nishida 13

PIC Microcontroller The PIC is one of the most popular microcontrollers. It uses a Harvard architecture and can be found in 8-bit, 16-bit and 32-bit families. Advantages: - PICBasic makes programming easier for beginners - Large sample code database - Wide range of packages and (onboard) features

Disadvantages: - A small instruction set - Memory must be directly referenced in arithmetic and logic operations - Only one accumulator

EEL 3923C, Fall 2010, T. Nishida 14

7 9/25/10

PIC Microcontroller (cont.)

Depending on the chip family, the PIC may include the following:

- General purpose I/O pins - Internal clock oscillators - 8/16/32 Bit Timers - Internal EEPROM Memory - Synchronous/Asynchronous Serial Interface USART - MSSP Peripheral for I²C and SPI Communications - Capture/Compare and PWM modules - Analog-to-digital converters (up to ~1.0 MHz) - USB, Ethernet, CAN interfacing support - External memory interface

EEL 3923C, Fall 2010, T. Nishida 15

PIC18F4620 Pinout Description (Preview)

EEL 3923C, Fall 2010, T. Nishida 16

8 9/25/10

PIC18F4620 Register Description (Preview)

EEL 3923C, Fall 2010, T. Nishida 17

PIC Compiler – MPLAB

EEL 3923C, Fall 2010, T. Nishida 18

9 9/25/10

PIC18F4620 Schematic

EEL 3923C, Fall 2010, T. Nishida 19

PIC Programmer – PICKit 2

EEL 3923C, Fall 2010, T. Nishida 20

10 9/25/10

Atmel AVR Microcontroller

AVRs are generally classified into five families: tinyAVR, megaAVR, XMEGA, application specific AVR and AT94K. It uses a modified Harvard architecture (RISC) and can be found in 8-bit and now 32-bit families.

Advantages: - C compiler with on chip debugging (OCD) - Large sample code database - Wide range of packages - Extensive peripheral set

EEL 3923C, Fall 2010, T. Nishida 21

Atmel AVR Microcontroller

Depending on the chip family, the AVR may include the following:

- Multifunction, bi-directional general purpose I/O ports with configurable, built-in pull-up resistors - Internal, self-programmable instruction flash memory - On chip debugging (OCD) - 8-Bit and 16-Bit timers - Analog comparator - 10 or 12-Bit A/D converters - A variety of serial interfaces (I2C, SPI, USI) - PWM control models - Ethernet controller support - LCD controller support - Low-voltage devices operating down to 1.8 V - Brownout detection

EEL 3923C, Fall 2010, T. Nishida 22

11 9/25/10

AVR ATMega32 Pinout Description (Sample)

EEL 3923C, Fall 2010, T. Nishida 23

AVR ATMega32 Register Description (Sample)

EEL 3923C, Fall 2010, T. Nishida 24

12 9/25/10

AVR Compiler – AVR Studio

EEL 3923C, Fall 2010, T. Nishida 25

AVR ATMega32 Schematic

EEL 3923C, Fall 2010, T. Nishida 26

13 9/25/10

AVR Programmer – AVR ISP MKII

EEL 3923C, Fall 2010, T. Nishida 27

TI MSP430 Microcontroller

The MSP430 microcontrollers are generally classified into four families: x1xx, x2xx, x3xx and x4xx. The MSP430 is based on a 16- bit architecture and is particularly well suited for wireless radio frequency engineering (RF) and battery-powered applications.

Advantages: - C compiler with on chip debugging (OCD) - Low cost - Free samples - LOW POWER CONSUMPTION!

EEL 3923C, Fall 2010, T. Nishida 28

14 9/25/10

TI MSP430 Microcontroller (cont.) The F2xx family MSP430 includes:

Power Specs Overview, as low as: - 0.1 μA RAM retention - 0.3 μA Standby mode (VLO) - 0.7 μA real-time clock mode - 220 μA / MIPS active -Feature Ultra-Fast Wake-Up From Standby Mode in <1 μs

Device Parameters: - Flash Options: 1–120 KiB - RAM Options: 128 B–8 KiB - GPIO Options: 10, 16, 24, 32, 48, 64 pins - ADC Options: Slope, 10 & 12-bit SAR, 16-bit Sigma Delta - Other Integrated peripherals: Analog Comparator, Hardware Multiplier, - DMA, SVS, 12-bit DAC, Op Amps

EEL 3923C, Fall 2010, T. Nishida 29

TI MSP430F2272 Pinout Description (Sample)

EEL 3923C, Fall 2010, T. Nishida 30

15 9/25/10

TI MSP430F2272 Register Description (Sample)

EEL 3923C, Fall 2010, T. Nishida 31

MSP430 Compiler – IAR Embedded Workbench

EEL 3923C, Fall 2010, T. Nishida 32

16 9/25/10

MSP430F2272 Schematic

EEL 3923C, Fall 2010, T. Nishida 33

References: Microcontroller Datasheets

PIC:

Microchip PIC18F4620

Atmel AVR: Atmel AVR ATMega324P

MSP430: TI MSP430F2272 Datasheet TI MSP430F2272 User Guide

EEL 3923C, Fall 2010, T. Nishida 34

17 9/25/10

References: Programmer Datasheets

PIC:

PICKit 2 Programmer

Atmel AVR: Atmel ARV ISP MKII

MSP430: TI MSP-FET430UIF Programmer

EEL 3923C, Fall 2010, T. Nishida 35

References: ‘Get Started’ Tutorials

PIC:

MPLAB Tutorial

Atmel AVR: AVR Studio Tutorial

MSP430: IAR Embedded Workbench Tutorial

EEL 3923C, Fall 2010, T. Nishida 36

18