1 / 22

MCU Micro Controller Unit

MCU Micro Controller Unit. 23/11/2005 – 14/12/2005 Andrea Aizza. Contenuti. Lezione 1 Introduzione ai microcontrollori MCU Microchip PIC16F877 Caratteristiche (prima parte) Set di istruzioni (prima parte) Pratica: come iniziare Hardware: configurazione ‘minima’

carver
Download Presentation

MCU Micro Controller Unit

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MCUMicro Controller Unit 23/11/2005 – 14/12/2005 Andrea Aizza

  2. Contenuti Lezione 1 • Introduzione ai microcontrollori • MCU Microchip • PIC16F877 • Caratteristiche (prima parte) • Set di istruzioni (prima parte) • Pratica: come iniziare • Hardware: configurazione ‘minima’ • Software: ‘Hello World’ • Tools: programmatore A. Aizza - 23/11/05

  3. Contenuti Lezione 2 • PIC16F877 • Caratteristiche (seconda parte) • Set di istruzioni (seconda parte) • Semplici tecniche di codifica • Tools: • Tools: ICD – In Circuit Debugger • Compilatore ANSI C per PIC18 A. Aizza - 23/11/05

  4. Contenuti Lezione 3 • Pratica: esperienza di laboratorio • LED + pulsante • LED + pulsante + anti-rimbalzo (hardware/software) • Misuratore di tensione con indicatore a LED • Trasmissione su porta seriale A. Aizza - 23/11/05

  5. Introduzione ai microcontrollori Microcontrollers: - Use internal RAM and ROM, so the external busses are available for general purpose I/O. Each bit can be assigned as an input or output. - Are generally used in very simple or lowcost designs. - Often have special ports: A/D converters, PWM outputs, USART, ...and so on. Microprocessors: - Use external RAM and ROM and require address and data busses to access them. - Are used for designs that require more I/O and memory. A. Aizza - 23/11/05

  6. MCU Microchip • Harvard Architecture • Instruction Pipelining • Long Word Instructions • Single Cycle Instructions • Single Word Instructions • Large Register File • Reduced Instruction Set • Orthogonal Instruction Set A. Aizza - 23/11/05

  7. MCU Microchip - Architecture • Traditional Von Neumann Architecture: • Fetches instructions and data from a single memory space • Limits operating bandwidth • Harvard Architecture: • Uses two separate memory spaces for program instructions and data • Improved operating bandwidth • Allows for different bus widths X12 = PIC16C5x, PIC12C5xx x14 = PIC16Cxxx, PIC14Cxxx, PIC12C6xx x16 = PIC17Cxxx x16 Enhanced = PIC18Cxxx A. Aizza - 23/11/05

  8. MCU Microchip - Pipelining Pipelining • In most micro controllers, instructions are fetched and executed sequentially • The pipelined architecture overlaps fetch and execution, making single cycle execution possible A. Aizza - 23/11/05

  9. MCU Microchip – Long Word Instruction Long Word Instruction • Separate instruction/data bus allows different bus widths • PIC16 word length optimized to 14-bits • Harvard architecture allows single word/single cycle instructions • 2k x 16 program memory on PICmicro roughly equivalent to 4k x 8 on other 8-bit microcontrollers • Single cycle access increases execution bandwidth A. Aizza - 23/11/05

  10. MCU Microchip - Register File Concept Register File Concept • Register File Concept: Unlike other RISC processors, all of data memory is part of the register file, so any location in data memory may be operated on directly • All peripherals are mapped into data memory as a series of registers • Orthogonal Instruction Set: ALL instructions can operate on ANY data memory location • The Long Word Instruction format allows a directly addressable register file Function Examples: addwf MyReg,w ; WREG = WREG + MyReg addwf MyReg,f ; MyReg = WREG + MyReg A. Aizza - 23/11/05

  11. PIC16F877 - Caratteristiche Caratteristiche principali • Velocita` massima: 20Mhz • Fino a 8K words (da 14bit) • Pinout compatibile con altri PIC16 • Internal timers (8bit e 16bit) • PWM (capture, compare) • SSP (SPI o IIC) • USART • PSP (slave) • Brown-out detection • 10bit A/D converter • Brown-out reset • Comparatore analogico • 256byte internal data EEPROM • Oscillatore configurabile • ICSP (debug/ICD) • Protezione del codice • Watch-dog timer • Modalita` SLEEP A. Aizza - 23/11/05

  12. PIC16F877 - Caratteristiche Caratteristiche principali • Descrizione generale • Piedinatura • Schema a blocchi • Oscillatore • Reset • Configuration Bits • Memoria dati • Memoria programma • Paging memoria programma • Registri speciali • Convertitore A/D • Interrupts • Manuale completo A. Aizza - 23/11/05

  13. PIC16F877 – Set di istruzioni Indirizzamento – Accesso alla Data Memory • Diretto: movwf <reg> • Indiretto: movwf INDF • Immediato (literal) movlw <const> A. Aizza - 23/11/05

  14. PIC16F877 – Set di istruzioni Indirizzamento – controllo di flusso • Assoluto: goto <addr> • Subroutine: call <addr> • Istruzioni ‘Skip’: btfss <reg>, <bit> A. Aizza - 23/11/05

  15. PIC16F877 – Set di istruzioni Classi di istruzioni: Control, Bit e Byte. A. Aizza - 23/11/05

  16. PIC16F877 – Set di istruzioni A. Aizza - 23/11/05

  17. Pratica – Configurazione hw minima Configurazione hardware minima • Alimentazione: +5Vdc (pin 11, 32), 0Vdc (pin 12, 31) • Clock: RC (pin 13) • Reset: +5Vdc  run, 0Vdc  reset (pin 1) Schema configurazione hardware minima A. Aizza - 23/11/05

  18. Pratica – Software Software: ‘Hello World’ Per far ‘funzionare’ un PIC serve: • Il codice da eseguire caricato nella program memory, • I configuration bits programmati in modo da rispecchiare le caratteristiche hardware. • ll file .hex, creato per esempio dall’assemblatore a partire dall’assembler o da un compilatore+assemblatore a partire dal linguaggio-C, contiene sempre il codice da eseguire assemblato. Puo` anche contenere i configuration bits. In caso contrario i configuration bits possono essere direttamente impostati tramite il programmatore. • Il codice da eseguire (e i configuration bits) vengono caricati nell’MCU tramite il programmatore. A. Aizza - 23/11/05

  19. Pratica – Software Multiple Source File Projects Relocatable Code Assembly Source File(s) Object File(s) Map File C Source File(s) Common Object File Format (COFF) Object Module File Used to generate HEX, COD and LST files: mp2cod.exe COD and LST mp2hex.exe HEX Library File (Collection of Pre-Compiled Object Files) Linker Script File A. Aizza - 23/11/05

  20. Pratica – Software ‘Hello World’ – ASM Software: ‘Hello World’ • Header: LIST P=16F877, F=INHX8M include <P16F877.inc> __CONFIG _CP_ALL & _DEBUG_OFF & ... errorlevel -302, -306, -202 radix dec • Inizio Codice: ASM – hello.asm org 0x00 goto Start org 0x04 goto ISR • Codice: Start ... A. Aizza - 23/11/05

  21. Pratica – Software – documenti utili Suggerimento... Quando si scrive codice ASM e` bene avere a disposizione: Manuale ASM: Quick ASM reference / ASM reference manual Il datasheet del PIC che si sta usando Il circuito per il quale si sta scrivendo il codice A. Aizza - 23/11/05

  22. Pratica – Tools: programmatore Come programmare un PIC? IC-Prog + JDM! Read, Write e Verify Codice in program memory Data EEPROM Configuration bits A. Aizza - 23/11/05

More Related