Top Banner
DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND 1 Introduction to Microcontrollers Tutorial: battery discharge monitoring PhD E. Marino Merlo Ultrasound and Non Destructive Testing Laboratory http:// www.uscndlab.dinfo.unifi.it/mdswitch.html
28

Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

Jul 11, 2018

Download

Documents

lytruc
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 1

Introduction to MicrocontrollersTutorial battery discharge monitoring

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 2

Summary

bull Integrated Development Environment (microcontrollers)bull Programming languagesbull Industrial electronics applicationbull Tutorial monitoring battery discharge using micro

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 3

Integrated Development Environment

bull Proprietary bull (Studio 7-gtATMEL MPLab X -gtMICROCHIP Composer Studio-gtTEXASbull Zilog Developper Studio -gt ZILOG hellip )

bull Proteus (Lab Center)bull (Environment to simulate some micro)

bull IAR Systembull (11071 devices)

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 4

Assembly

Language C

Programming languages

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 5

Language C Language ASM

include ltavriohgtdefine uchar unsigned chardefine uint unsigned int

Low level portpin definitionsdefine sbit(xPORT) (PORT) |= (1ltltx)define pin(xPIN) (PIN)amp(1ltltx)

int main(void) SPL = 0x5f

SPH = 0x04helliphellipOCR0 = 0x01 Foc = Fclk2(1+OCR0)

Configure the channel IN0helliphellip

-------------- MAIN ROUTINE --------------BEEP CLR IBLUPE

SER A TURN SPKR ONOUT PORTBARCALL PAUSE WAIT

CLR A TURN IT OFFOUT PORTBARCALL PAUSE WAIT AGAIN

DEC IBRNE BLUPE

LOOP RJMP LOOP STAY HERE WHEN DONE

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Applications of industrial electronic

bull Digital Broadcast applications

bull Medical Applications

bull Automotive application

bull Wireless Connectivity

bull Smart Energy

bull Drivers and Sensors

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 7

ENERGY STORAGE

compressed air energy storage

flywheel storage

pumped water storage

superconducting magnetic energy storage

1 - 10 WmiddothkgSPECIFIC ENERGY

Tutorial battery discharge monitoring

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 8

A battery is an energy storage device that uses a chemical reaction to dowork on charge and produce a voltage between its output terminals Abattery is composed of one or more basic elements known as electrolyticcells (or electrochemical cells) and makes use of an oxidation-reductionreaction These cells are enclosed in a container and electricallyinterconnected in an appropriate seriesparallel arrangement to provide therequired operating voltage and current levels

History

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 9

PRIMARY CELLSor non-rechargeable batteries

alkaline battery

carbon zinc batteryabsorbed glass mat

fuel cell

gel-type battery

lead-acid battery

lithium-sulfur battery

BATTERIES

SECONDARY CELLSor rechargeable batteries

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 10

How is made lead-acid battery

httpwwwdaviddarlinginfoencyclopediaLAE_lead-acid_batteryhtml

The lead-acid battery was invented in 1859 by French phisicist Gaston Plantegrave and is oldest type of recheargeable battery An electrochemical battery that uses lead and lead oxide for electrodes and sulfuric acid for the electrolyteLow energy-to-weight ratioLow energy-to-volume ratioLarge power to weigth ratioSpecific energy 33ndash42 WhkgEnergy density 60ndash110 WhL Specific power 180 WkgCycle durability 500ndash800 cycles Nominal cell voltage 20 V

Shallow cycle batteries like the type used as starting batteries in automobiles are designed to supply a large amount of current for a short time and stand mild overcharge without losing electrolyte Unfortunately they cannot tolerate being deeply discharged If they are repeatedly discharged more than 20 percent their life will be very short These batteries are not a good choice for a PV system

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 11

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 12

How it works

Attention Risk of explosion for Excessive Charging

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 13

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Charge Monitoring

Battery State of Charge DeterminationCircuit Voltage and the Remaining Capacity at constant temperature

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DISCHARGE Monitoring

C = 7Ah in our battery

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 2: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 2

Summary

bull Integrated Development Environment (microcontrollers)bull Programming languagesbull Industrial electronics applicationbull Tutorial monitoring battery discharge using micro

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 3

Integrated Development Environment

bull Proprietary bull (Studio 7-gtATMEL MPLab X -gtMICROCHIP Composer Studio-gtTEXASbull Zilog Developper Studio -gt ZILOG hellip )

bull Proteus (Lab Center)bull (Environment to simulate some micro)

bull IAR Systembull (11071 devices)

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 4

Assembly

Language C

Programming languages

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 5

Language C Language ASM

include ltavriohgtdefine uchar unsigned chardefine uint unsigned int

Low level portpin definitionsdefine sbit(xPORT) (PORT) |= (1ltltx)define pin(xPIN) (PIN)amp(1ltltx)

int main(void) SPL = 0x5f

SPH = 0x04helliphellipOCR0 = 0x01 Foc = Fclk2(1+OCR0)

Configure the channel IN0helliphellip

-------------- MAIN ROUTINE --------------BEEP CLR IBLUPE

SER A TURN SPKR ONOUT PORTBARCALL PAUSE WAIT

CLR A TURN IT OFFOUT PORTBARCALL PAUSE WAIT AGAIN

DEC IBRNE BLUPE

LOOP RJMP LOOP STAY HERE WHEN DONE

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Applications of industrial electronic

bull Digital Broadcast applications

bull Medical Applications

bull Automotive application

bull Wireless Connectivity

bull Smart Energy

bull Drivers and Sensors

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 7

ENERGY STORAGE

compressed air energy storage

flywheel storage

pumped water storage

superconducting magnetic energy storage

1 - 10 WmiddothkgSPECIFIC ENERGY

Tutorial battery discharge monitoring

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 8

A battery is an energy storage device that uses a chemical reaction to dowork on charge and produce a voltage between its output terminals Abattery is composed of one or more basic elements known as electrolyticcells (or electrochemical cells) and makes use of an oxidation-reductionreaction These cells are enclosed in a container and electricallyinterconnected in an appropriate seriesparallel arrangement to provide therequired operating voltage and current levels

History

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 9

PRIMARY CELLSor non-rechargeable batteries

alkaline battery

carbon zinc batteryabsorbed glass mat

fuel cell

gel-type battery

lead-acid battery

lithium-sulfur battery

BATTERIES

SECONDARY CELLSor rechargeable batteries

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 10

How is made lead-acid battery

httpwwwdaviddarlinginfoencyclopediaLAE_lead-acid_batteryhtml

The lead-acid battery was invented in 1859 by French phisicist Gaston Plantegrave and is oldest type of recheargeable battery An electrochemical battery that uses lead and lead oxide for electrodes and sulfuric acid for the electrolyteLow energy-to-weight ratioLow energy-to-volume ratioLarge power to weigth ratioSpecific energy 33ndash42 WhkgEnergy density 60ndash110 WhL Specific power 180 WkgCycle durability 500ndash800 cycles Nominal cell voltage 20 V

Shallow cycle batteries like the type used as starting batteries in automobiles are designed to supply a large amount of current for a short time and stand mild overcharge without losing electrolyte Unfortunately they cannot tolerate being deeply discharged If they are repeatedly discharged more than 20 percent their life will be very short These batteries are not a good choice for a PV system

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 11

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 12

How it works

Attention Risk of explosion for Excessive Charging

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 13

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Charge Monitoring

Battery State of Charge DeterminationCircuit Voltage and the Remaining Capacity at constant temperature

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DISCHARGE Monitoring

C = 7Ah in our battery

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 3: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 3

Integrated Development Environment

bull Proprietary bull (Studio 7-gtATMEL MPLab X -gtMICROCHIP Composer Studio-gtTEXASbull Zilog Developper Studio -gt ZILOG hellip )

bull Proteus (Lab Center)bull (Environment to simulate some micro)

bull IAR Systembull (11071 devices)

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 4

Assembly

Language C

Programming languages

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 5

Language C Language ASM

include ltavriohgtdefine uchar unsigned chardefine uint unsigned int

Low level portpin definitionsdefine sbit(xPORT) (PORT) |= (1ltltx)define pin(xPIN) (PIN)amp(1ltltx)

int main(void) SPL = 0x5f

SPH = 0x04helliphellipOCR0 = 0x01 Foc = Fclk2(1+OCR0)

Configure the channel IN0helliphellip

-------------- MAIN ROUTINE --------------BEEP CLR IBLUPE

SER A TURN SPKR ONOUT PORTBARCALL PAUSE WAIT

CLR A TURN IT OFFOUT PORTBARCALL PAUSE WAIT AGAIN

DEC IBRNE BLUPE

LOOP RJMP LOOP STAY HERE WHEN DONE

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Applications of industrial electronic

bull Digital Broadcast applications

bull Medical Applications

bull Automotive application

bull Wireless Connectivity

bull Smart Energy

bull Drivers and Sensors

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 7

ENERGY STORAGE

compressed air energy storage

flywheel storage

pumped water storage

superconducting magnetic energy storage

1 - 10 WmiddothkgSPECIFIC ENERGY

Tutorial battery discharge monitoring

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 8

A battery is an energy storage device that uses a chemical reaction to dowork on charge and produce a voltage between its output terminals Abattery is composed of one or more basic elements known as electrolyticcells (or electrochemical cells) and makes use of an oxidation-reductionreaction These cells are enclosed in a container and electricallyinterconnected in an appropriate seriesparallel arrangement to provide therequired operating voltage and current levels

History

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 9

PRIMARY CELLSor non-rechargeable batteries

alkaline battery

carbon zinc batteryabsorbed glass mat

fuel cell

gel-type battery

lead-acid battery

lithium-sulfur battery

BATTERIES

SECONDARY CELLSor rechargeable batteries

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 10

How is made lead-acid battery

httpwwwdaviddarlinginfoencyclopediaLAE_lead-acid_batteryhtml

The lead-acid battery was invented in 1859 by French phisicist Gaston Plantegrave and is oldest type of recheargeable battery An electrochemical battery that uses lead and lead oxide for electrodes and sulfuric acid for the electrolyteLow energy-to-weight ratioLow energy-to-volume ratioLarge power to weigth ratioSpecific energy 33ndash42 WhkgEnergy density 60ndash110 WhL Specific power 180 WkgCycle durability 500ndash800 cycles Nominal cell voltage 20 V

Shallow cycle batteries like the type used as starting batteries in automobiles are designed to supply a large amount of current for a short time and stand mild overcharge without losing electrolyte Unfortunately they cannot tolerate being deeply discharged If they are repeatedly discharged more than 20 percent their life will be very short These batteries are not a good choice for a PV system

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 11

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 12

How it works

Attention Risk of explosion for Excessive Charging

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 13

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Charge Monitoring

Battery State of Charge DeterminationCircuit Voltage and the Remaining Capacity at constant temperature

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DISCHARGE Monitoring

C = 7Ah in our battery

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 4: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 4

Assembly

Language C

Programming languages

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 5

Language C Language ASM

include ltavriohgtdefine uchar unsigned chardefine uint unsigned int

Low level portpin definitionsdefine sbit(xPORT) (PORT) |= (1ltltx)define pin(xPIN) (PIN)amp(1ltltx)

int main(void) SPL = 0x5f

SPH = 0x04helliphellipOCR0 = 0x01 Foc = Fclk2(1+OCR0)

Configure the channel IN0helliphellip

-------------- MAIN ROUTINE --------------BEEP CLR IBLUPE

SER A TURN SPKR ONOUT PORTBARCALL PAUSE WAIT

CLR A TURN IT OFFOUT PORTBARCALL PAUSE WAIT AGAIN

DEC IBRNE BLUPE

LOOP RJMP LOOP STAY HERE WHEN DONE

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Applications of industrial electronic

bull Digital Broadcast applications

bull Medical Applications

bull Automotive application

bull Wireless Connectivity

bull Smart Energy

bull Drivers and Sensors

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 7

ENERGY STORAGE

compressed air energy storage

flywheel storage

pumped water storage

superconducting magnetic energy storage

1 - 10 WmiddothkgSPECIFIC ENERGY

Tutorial battery discharge monitoring

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 8

A battery is an energy storage device that uses a chemical reaction to dowork on charge and produce a voltage between its output terminals Abattery is composed of one or more basic elements known as electrolyticcells (or electrochemical cells) and makes use of an oxidation-reductionreaction These cells are enclosed in a container and electricallyinterconnected in an appropriate seriesparallel arrangement to provide therequired operating voltage and current levels

History

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 9

PRIMARY CELLSor non-rechargeable batteries

alkaline battery

carbon zinc batteryabsorbed glass mat

fuel cell

gel-type battery

lead-acid battery

lithium-sulfur battery

BATTERIES

SECONDARY CELLSor rechargeable batteries

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 10

How is made lead-acid battery

httpwwwdaviddarlinginfoencyclopediaLAE_lead-acid_batteryhtml

The lead-acid battery was invented in 1859 by French phisicist Gaston Plantegrave and is oldest type of recheargeable battery An electrochemical battery that uses lead and lead oxide for electrodes and sulfuric acid for the electrolyteLow energy-to-weight ratioLow energy-to-volume ratioLarge power to weigth ratioSpecific energy 33ndash42 WhkgEnergy density 60ndash110 WhL Specific power 180 WkgCycle durability 500ndash800 cycles Nominal cell voltage 20 V

Shallow cycle batteries like the type used as starting batteries in automobiles are designed to supply a large amount of current for a short time and stand mild overcharge without losing electrolyte Unfortunately they cannot tolerate being deeply discharged If they are repeatedly discharged more than 20 percent their life will be very short These batteries are not a good choice for a PV system

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 11

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 12

How it works

Attention Risk of explosion for Excessive Charging

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 13

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Charge Monitoring

Battery State of Charge DeterminationCircuit Voltage and the Remaining Capacity at constant temperature

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DISCHARGE Monitoring

C = 7Ah in our battery

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 5: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 5

Language C Language ASM

include ltavriohgtdefine uchar unsigned chardefine uint unsigned int

Low level portpin definitionsdefine sbit(xPORT) (PORT) |= (1ltltx)define pin(xPIN) (PIN)amp(1ltltx)

int main(void) SPL = 0x5f

SPH = 0x04helliphellipOCR0 = 0x01 Foc = Fclk2(1+OCR0)

Configure the channel IN0helliphellip

-------------- MAIN ROUTINE --------------BEEP CLR IBLUPE

SER A TURN SPKR ONOUT PORTBARCALL PAUSE WAIT

CLR A TURN IT OFFOUT PORTBARCALL PAUSE WAIT AGAIN

DEC IBRNE BLUPE

LOOP RJMP LOOP STAY HERE WHEN DONE

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Applications of industrial electronic

bull Digital Broadcast applications

bull Medical Applications

bull Automotive application

bull Wireless Connectivity

bull Smart Energy

bull Drivers and Sensors

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 7

ENERGY STORAGE

compressed air energy storage

flywheel storage

pumped water storage

superconducting magnetic energy storage

1 - 10 WmiddothkgSPECIFIC ENERGY

Tutorial battery discharge monitoring

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 8

A battery is an energy storage device that uses a chemical reaction to dowork on charge and produce a voltage between its output terminals Abattery is composed of one or more basic elements known as electrolyticcells (or electrochemical cells) and makes use of an oxidation-reductionreaction These cells are enclosed in a container and electricallyinterconnected in an appropriate seriesparallel arrangement to provide therequired operating voltage and current levels

History

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 9

PRIMARY CELLSor non-rechargeable batteries

alkaline battery

carbon zinc batteryabsorbed glass mat

fuel cell

gel-type battery

lead-acid battery

lithium-sulfur battery

BATTERIES

SECONDARY CELLSor rechargeable batteries

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 10

How is made lead-acid battery

httpwwwdaviddarlinginfoencyclopediaLAE_lead-acid_batteryhtml

The lead-acid battery was invented in 1859 by French phisicist Gaston Plantegrave and is oldest type of recheargeable battery An electrochemical battery that uses lead and lead oxide for electrodes and sulfuric acid for the electrolyteLow energy-to-weight ratioLow energy-to-volume ratioLarge power to weigth ratioSpecific energy 33ndash42 WhkgEnergy density 60ndash110 WhL Specific power 180 WkgCycle durability 500ndash800 cycles Nominal cell voltage 20 V

Shallow cycle batteries like the type used as starting batteries in automobiles are designed to supply a large amount of current for a short time and stand mild overcharge without losing electrolyte Unfortunately they cannot tolerate being deeply discharged If they are repeatedly discharged more than 20 percent their life will be very short These batteries are not a good choice for a PV system

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 11

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 12

How it works

Attention Risk of explosion for Excessive Charging

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 13

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Charge Monitoring

Battery State of Charge DeterminationCircuit Voltage and the Remaining Capacity at constant temperature

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DISCHARGE Monitoring

C = 7Ah in our battery

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 6: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Applications of industrial electronic

bull Digital Broadcast applications

bull Medical Applications

bull Automotive application

bull Wireless Connectivity

bull Smart Energy

bull Drivers and Sensors

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 7

ENERGY STORAGE

compressed air energy storage

flywheel storage

pumped water storage

superconducting magnetic energy storage

1 - 10 WmiddothkgSPECIFIC ENERGY

Tutorial battery discharge monitoring

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 8

A battery is an energy storage device that uses a chemical reaction to dowork on charge and produce a voltage between its output terminals Abattery is composed of one or more basic elements known as electrolyticcells (or electrochemical cells) and makes use of an oxidation-reductionreaction These cells are enclosed in a container and electricallyinterconnected in an appropriate seriesparallel arrangement to provide therequired operating voltage and current levels

History

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 9

PRIMARY CELLSor non-rechargeable batteries

alkaline battery

carbon zinc batteryabsorbed glass mat

fuel cell

gel-type battery

lead-acid battery

lithium-sulfur battery

BATTERIES

SECONDARY CELLSor rechargeable batteries

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 10

How is made lead-acid battery

httpwwwdaviddarlinginfoencyclopediaLAE_lead-acid_batteryhtml

The lead-acid battery was invented in 1859 by French phisicist Gaston Plantegrave and is oldest type of recheargeable battery An electrochemical battery that uses lead and lead oxide for electrodes and sulfuric acid for the electrolyteLow energy-to-weight ratioLow energy-to-volume ratioLarge power to weigth ratioSpecific energy 33ndash42 WhkgEnergy density 60ndash110 WhL Specific power 180 WkgCycle durability 500ndash800 cycles Nominal cell voltage 20 V

Shallow cycle batteries like the type used as starting batteries in automobiles are designed to supply a large amount of current for a short time and stand mild overcharge without losing electrolyte Unfortunately they cannot tolerate being deeply discharged If they are repeatedly discharged more than 20 percent their life will be very short These batteries are not a good choice for a PV system

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 11

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 12

How it works

Attention Risk of explosion for Excessive Charging

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 13

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Charge Monitoring

Battery State of Charge DeterminationCircuit Voltage and the Remaining Capacity at constant temperature

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DISCHARGE Monitoring

C = 7Ah in our battery

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 7: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 7

ENERGY STORAGE

compressed air energy storage

flywheel storage

pumped water storage

superconducting magnetic energy storage

1 - 10 WmiddothkgSPECIFIC ENERGY

Tutorial battery discharge monitoring

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 8

A battery is an energy storage device that uses a chemical reaction to dowork on charge and produce a voltage between its output terminals Abattery is composed of one or more basic elements known as electrolyticcells (or electrochemical cells) and makes use of an oxidation-reductionreaction These cells are enclosed in a container and electricallyinterconnected in an appropriate seriesparallel arrangement to provide therequired operating voltage and current levels

History

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 9

PRIMARY CELLSor non-rechargeable batteries

alkaline battery

carbon zinc batteryabsorbed glass mat

fuel cell

gel-type battery

lead-acid battery

lithium-sulfur battery

BATTERIES

SECONDARY CELLSor rechargeable batteries

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 10

How is made lead-acid battery

httpwwwdaviddarlinginfoencyclopediaLAE_lead-acid_batteryhtml

The lead-acid battery was invented in 1859 by French phisicist Gaston Plantegrave and is oldest type of recheargeable battery An electrochemical battery that uses lead and lead oxide for electrodes and sulfuric acid for the electrolyteLow energy-to-weight ratioLow energy-to-volume ratioLarge power to weigth ratioSpecific energy 33ndash42 WhkgEnergy density 60ndash110 WhL Specific power 180 WkgCycle durability 500ndash800 cycles Nominal cell voltage 20 V

Shallow cycle batteries like the type used as starting batteries in automobiles are designed to supply a large amount of current for a short time and stand mild overcharge without losing electrolyte Unfortunately they cannot tolerate being deeply discharged If they are repeatedly discharged more than 20 percent their life will be very short These batteries are not a good choice for a PV system

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 11

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 12

How it works

Attention Risk of explosion for Excessive Charging

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 13

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Charge Monitoring

Battery State of Charge DeterminationCircuit Voltage and the Remaining Capacity at constant temperature

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DISCHARGE Monitoring

C = 7Ah in our battery

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 8: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 8

A battery is an energy storage device that uses a chemical reaction to dowork on charge and produce a voltage between its output terminals Abattery is composed of one or more basic elements known as electrolyticcells (or electrochemical cells) and makes use of an oxidation-reductionreaction These cells are enclosed in a container and electricallyinterconnected in an appropriate seriesparallel arrangement to provide therequired operating voltage and current levels

History

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 9

PRIMARY CELLSor non-rechargeable batteries

alkaline battery

carbon zinc batteryabsorbed glass mat

fuel cell

gel-type battery

lead-acid battery

lithium-sulfur battery

BATTERIES

SECONDARY CELLSor rechargeable batteries

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 10

How is made lead-acid battery

httpwwwdaviddarlinginfoencyclopediaLAE_lead-acid_batteryhtml

The lead-acid battery was invented in 1859 by French phisicist Gaston Plantegrave and is oldest type of recheargeable battery An electrochemical battery that uses lead and lead oxide for electrodes and sulfuric acid for the electrolyteLow energy-to-weight ratioLow energy-to-volume ratioLarge power to weigth ratioSpecific energy 33ndash42 WhkgEnergy density 60ndash110 WhL Specific power 180 WkgCycle durability 500ndash800 cycles Nominal cell voltage 20 V

Shallow cycle batteries like the type used as starting batteries in automobiles are designed to supply a large amount of current for a short time and stand mild overcharge without losing electrolyte Unfortunately they cannot tolerate being deeply discharged If they are repeatedly discharged more than 20 percent their life will be very short These batteries are not a good choice for a PV system

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 11

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 12

How it works

Attention Risk of explosion for Excessive Charging

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 13

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Charge Monitoring

Battery State of Charge DeterminationCircuit Voltage and the Remaining Capacity at constant temperature

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DISCHARGE Monitoring

C = 7Ah in our battery

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 9: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 9

PRIMARY CELLSor non-rechargeable batteries

alkaline battery

carbon zinc batteryabsorbed glass mat

fuel cell

gel-type battery

lead-acid battery

lithium-sulfur battery

BATTERIES

SECONDARY CELLSor rechargeable batteries

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 10

How is made lead-acid battery

httpwwwdaviddarlinginfoencyclopediaLAE_lead-acid_batteryhtml

The lead-acid battery was invented in 1859 by French phisicist Gaston Plantegrave and is oldest type of recheargeable battery An electrochemical battery that uses lead and lead oxide for electrodes and sulfuric acid for the electrolyteLow energy-to-weight ratioLow energy-to-volume ratioLarge power to weigth ratioSpecific energy 33ndash42 WhkgEnergy density 60ndash110 WhL Specific power 180 WkgCycle durability 500ndash800 cycles Nominal cell voltage 20 V

Shallow cycle batteries like the type used as starting batteries in automobiles are designed to supply a large amount of current for a short time and stand mild overcharge without losing electrolyte Unfortunately they cannot tolerate being deeply discharged If they are repeatedly discharged more than 20 percent their life will be very short These batteries are not a good choice for a PV system

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 11

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 12

How it works

Attention Risk of explosion for Excessive Charging

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 13

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Charge Monitoring

Battery State of Charge DeterminationCircuit Voltage and the Remaining Capacity at constant temperature

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DISCHARGE Monitoring

C = 7Ah in our battery

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 10: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 10

How is made lead-acid battery

httpwwwdaviddarlinginfoencyclopediaLAE_lead-acid_batteryhtml

The lead-acid battery was invented in 1859 by French phisicist Gaston Plantegrave and is oldest type of recheargeable battery An electrochemical battery that uses lead and lead oxide for electrodes and sulfuric acid for the electrolyteLow energy-to-weight ratioLow energy-to-volume ratioLarge power to weigth ratioSpecific energy 33ndash42 WhkgEnergy density 60ndash110 WhL Specific power 180 WkgCycle durability 500ndash800 cycles Nominal cell voltage 20 V

Shallow cycle batteries like the type used as starting batteries in automobiles are designed to supply a large amount of current for a short time and stand mild overcharge without losing electrolyte Unfortunately they cannot tolerate being deeply discharged If they are repeatedly discharged more than 20 percent their life will be very short These batteries are not a good choice for a PV system

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 11

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 12

How it works

Attention Risk of explosion for Excessive Charging

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 13

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Charge Monitoring

Battery State of Charge DeterminationCircuit Voltage and the Remaining Capacity at constant temperature

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DISCHARGE Monitoring

C = 7Ah in our battery

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 11: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 11

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 12

How it works

Attention Risk of explosion for Excessive Charging

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 13

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Charge Monitoring

Battery State of Charge DeterminationCircuit Voltage and the Remaining Capacity at constant temperature

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DISCHARGE Monitoring

C = 7Ah in our battery

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 12: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 12

How it works

Attention Risk of explosion for Excessive Charging

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 13

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Charge Monitoring

Battery State of Charge DeterminationCircuit Voltage and the Remaining Capacity at constant temperature

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DISCHARGE Monitoring

C = 7Ah in our battery

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 13: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 13

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Charge Monitoring

Battery State of Charge DeterminationCircuit Voltage and the Remaining Capacity at constant temperature

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DISCHARGE Monitoring

C = 7Ah in our battery

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 14: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

Charge Monitoring

Battery State of Charge DeterminationCircuit Voltage and the Remaining Capacity at constant temperature

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DISCHARGE Monitoring

C = 7Ah in our battery

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 15: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DISCHARGE Monitoring

C = 7Ah in our battery

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 16: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 17: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 17

Bibliography

bullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullhttpwwwatmelcom

bullWikipedia

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 18: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - Lab USCND 18

Introduction to Microcontrollersarchitecture

PhD E Marino Merlo

Ultrasound and Non Destructive Testing Laboratoryhttpwwwuscndlabdinfounifiitmdswitchhtml

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 19: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 19

Summary

Microcontrollers

bull Pinoutbull Block diagrambull Featuresbull Demo board Xplainedbull Examples and simulation with Proteus

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 20: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 20

PINOUT

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 21: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 21

Block Diagram

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 22: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 22

Microcontroller featuresLow-power Atmelreg AVRreg XMEGAreg 816-bit MicrocontrollerNon volatile program and data memories64K - 128KBytes of in-system self-programmable flash4K - 8KBytes boot section2 KBytes EEPROM4 KB - 8 KBytes internal SRAMEight 16-bit timercountersFour timercounters with 4 output compare or input capture channelsEight USARTs with IrDA support for one USARTFour two-wire interfaces with dual address match (I2C and SMBus compatible)16-bit real time counter (RTC) with separate oscillatorTwo sixteen channel 12-bit 2msps Analog to Digital ConvertersTwo two-channel 12-bit 1msps Digital to Analog ConvertersFour Analog Comparators (ACs) with window compare function and current sources

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 23: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 23

bullMicrocontroller features

bull External interrupts on all general purpose IO pinsbull Programmable watchdog timer with separate on-chip ultra low powerbull QTouchreg library supportbull Internal and external clock options with PLL and prescalerbull Programmable multilevel interrupt controller bull Executing instructions in a single clock cyclebull 32 general purpose working registers directly connected to the arithmetic logic unit

(ALU)bull Two independent registers to be accessed in a single Instructionbull 78 general purpose IO linesbull 16-bit real-time counter (RTC) bull Eight flexible 16-bit timercounters with compare and PWM channelsbull Two 16-channel 12-bit ADCs with programmable gain

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 24: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

XMEGA-A1 Xplained

Matching buttons

PD0 lt- Button 1PD1 lt- Button 2PD2 lt- Button 3PD3 lt- Button 4PD4 lt- Button 5PD5 lt- Button 6PR0 lt- Button 7PR1 lt- Button 8

Mappatura Led

LED1 lt- PE0LED2 lt- PE1LED3 lt- PE2LED4 lt- PE3LED5 lt- PE4LED6 lt- PE5LED7 lt- PE6LED8 lt- PE7

Sensore NTC -gt PB0 -gt Conv Analogico DigitaleSensore Luminositagrave -gt PB1 -gt Conv Analogico DigitaleDAC -gt PB2 -gt Speaker

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 25: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 25

JTAG

The Joint Test Action Group (JTAG) is an electronics industry association formed in 1985

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 26: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 26

Example 1 LEDs turn on with push button

FILE NAME iocCHIP TYPE ATMEGA16CLOCK FREQUENCY 8MHZIDE VSMStudioCOMPILER PhD Eugenio Marino MerloTIME 3052016include ltavriohgtinclude ltutildelayhgt

Main Program

int main(void)

DDRD =0x00 PORTD=0xff pins portd as input pull-upDDRB=0xff PORTB=0x00 portb as outputs int a=0x00

while(1) forever

if (PIND =0xff) a=~a if (PIND ==0xff) a=0x01 if (PIND ==0xfe) a=0xfe PORTB=a

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 27: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 27

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28
Page 28: Introduction to Microcontrollers - UniFI · DINFO Dipartimento di Ingegneria dell’Informazione Department of Information Engineering 07/06/2016 Eugenio Marino Merlo - Lab. USCND

DINFODipartimento di Ingegneria dellrsquoInformazione Department of Information Engineering

07062016 Eugenio Marino Merlo - PhD 20152018 - Lab USCND 28

BibliographybullhttpwwwdaviddarlinginfoencyclopediaBAE_batteryhtml

bullWikipedia

  • Diapositiva numero 1
  • Summary
  • Integrated Development Environment
  • Diapositiva numero 4
  • Language C Language ASM
  • Diapositiva numero 6
  • Diapositiva numero 7
  • Diapositiva numero 8
  • Diapositiva numero 9
  • Diapositiva numero 10
  • Diapositiva numero 11
  • Diapositiva numero 12
  • Diapositiva numero 13
  • Diapositiva numero 14
  • Diapositiva numero 15
  • Diapositiva numero 16
  • Diapositiva numero 17
  • Diapositiva numero 18
  • Summary
  • Diapositiva numero 20
  • Diapositiva numero 21
  • Diapositiva numero 22
  • Diapositiva numero 23
  • Diapositiva numero 24
  • JTAG
  • Diapositiva numero 26
  • Diapositiva numero 27
  • Diapositiva numero 28