18
9/25/10 1 EEL 3923C JD/ Module 4 – Introduction to Microcontrollers Ryan Nuzzaci Fall 2010 2 EEL 3923C, Fall 2010, T. Nishida Introduction to Microcontrollers A microcontroller is a small, special purpose chip used in embedded system designs. It has an internal bus with in built memory and peripherals whereas a microprocessor does not. Common uses: Digital assistants (PDAs), MP3 players Mobile phones Videogame consoles Digital cameras DVD players GPS receivers Computer peripherals Household appliances

JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

Embed Size (px)

Citation preview

Page 1: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

1

EEL 3923C JD/ Module 4 – Introduction to Microcontrollers

Ryan Nuzzaci���Fall 2010

2 EEL 3923C, Fall 2010, T. Nishida

Introduction to Microcontrollers A microcontroller is a small, special purpose chip used in embedded system designs. It has an internal bus with in built memory and peripherals whereas a microprocessor does not.

Common uses:

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

Page 2: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

2

3 EEL 3923C, Fall 2010, T. Nishida

Microcontroller Components

Common integrated peripherals:

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

4 EEL 3923C, Fall 2010, T. Nishida

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

Page 3: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

3

5 EEL 3923C, Fall 2010, T. Nishida

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).

6 EEL 3923C, Fall 2010, T. Nishida

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/

Page 4: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

4

7 EEL 3923C, Fall 2010, T. Nishida

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

8 EEL 3923C, Fall 2010, T. Nishida

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.

Page 5: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

5

9 EEL 3923C, Fall 2010, T. Nishida

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)

10 EEL 3923C, Fall 2010, T. Nishida

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).

Page 6: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

6

11 EEL 3923C, Fall 2010, T. Nishida

Block Diagram

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

12 EEL 3923C, Fall 2010, T. Nishida

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 compiler

•  Language (high level/low level) 4. Test and debug

o  Simulators o  Debuggers (JTAG)

Page 7: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

7

13 EEL 3923C, Fall 2010, T. Nishida

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

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

14 EEL 3923C, Fall 2010, T. Nishida

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

Page 8: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

8

15 EEL 3923C, Fall 2010, T. Nishida

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

16 EEL 3923C, Fall 2010, T. Nishida

PIC18F4620 Pinout Description (Preview)

Page 9: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

9

17 EEL 3923C, Fall 2010, T. Nishida

PIC18F4620 Register Description (Preview)

18 EEL 3923C, Fall 2010, T. Nishida

PIC Compiler – MPLAB

Page 10: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

10

19 EEL 3923C, Fall 2010, T. Nishida

PIC18F4620 Schematic

20 EEL 3923C, Fall 2010, T. Nishida

PIC Programmer – PICKit 2

Page 11: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

11

21 EEL 3923C, Fall 2010, T. Nishida

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

22 EEL 3923C, Fall 2010, T. Nishida

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

Page 12: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

12

23 EEL 3923C, Fall 2010, T. Nishida

AVR ATMega32 Pinout Description (Sample)

24 EEL 3923C, Fall 2010, T. Nishida

AVR ATMega32 Register Description (Sample)

Page 13: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

13

25 EEL 3923C, Fall 2010, T. Nishida

AVR Compiler – AVR Studio

26 EEL 3923C, Fall 2010, T. Nishida

AVR ATMega32 Schematic

Page 14: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

14

27 EEL 3923C, Fall 2010, T. Nishida

AVR Programmer – AVR ISP MKII

28 EEL 3923C, Fall 2010, T. Nishida

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!

Page 15: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

15

29 EEL 3923C, Fall 2010, T. Nishida

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

30 EEL 3923C, Fall 2010, T. Nishida

TI MSP430F2272 Pinout Description (Sample)

Page 16: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

16

31 EEL 3923C, Fall 2010, T. Nishida

TI MSP430F2272 Register Description (Sample)

32 EEL 3923C, Fall 2010, T. Nishida

MSP430 Compiler – IAR Embedded Workbench

Page 17: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

17

33 EEL 3923C, Fall 2010, T. Nishida

MSP430F2272 Schematic

34 EEL 3923C, Fall 2010, T. Nishida

References: Microcontroller Datasheets PIC:

Atmel AVR:

MSP430: TI MSP430F2272 Datasheet TI MSP430F2272 User Guide

Atmel AVR ATMega324P

Microchip PIC18F4620

Page 18: JD Module4 V1 - University of Florida Microcontroller! ... PIC Programmer – PICKit 2! 9/25/10! 11! EEL 3923C, Fall 2010, T. Nishida 21 Atmel AVR Microcontroller! ... JD_Module4_V1.ppt

9/25/10

18

35 EEL 3923C, Fall 2010, T. Nishida

References: Programmer Datasheets PIC:

Atmel AVR:

MSP430: TI MSP-FET430UIF Programmer

Atmel ARV ISP MKII

PICKit 2 Programmer

36 EEL 3923C, Fall 2010, T. Nishida

References: ‘Get Started’ Tutorials PIC:

Atmel AVR:

MSP430: IAR Embedded Workbench Tutorial

AVR Studio Tutorial

MPLAB Tutorial