N 1230 ELETTRONICA DEI SISTEMI DIGITALI DI FISSORE GIORGIO - Appunti Universitari Online

Pagina creata da Laura De Simone
 
CONTINUA A LEGGERE
N 1230 ELETTRONICA DEI SISTEMI DIGITALI DI FISSORE GIORGIO - Appunti Universitari Online
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                       1 di 334

                                                Centro Stampa
        ATTENZIONE QUESTI APPUNTI SONO OPERA DI STUDENTI , NON SONO STATI VISIONATI
        DAL DOCENTE. IL NOME DEL PROFESSORE, SERVE SOLO PER IDENTIFICARE IL CORSO.

                                                              N° 1230

               ELETTRONICA DEI SISTEMI DIGITALI

             DI FISSORE GIORGIO

Centro stampa Copysprinter – Stampa Autorizzata dall’autore                       1 di 334
N 1230 ELETTRONICA DEI SISTEMI DIGITALI DI FISSORE GIORGIO - Appunti Universitari Online
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                             2 di 334

                MicroController Concepts

  Appunti presi a partire dalle video-lezioni di Elettronica                            Nella prima metà del corso abbiamo
  dei Sistemi Digitali, aa. 2013/2014.                                                  imparato a progettare l'hw, sia nella sua
                                                                                        unità di esecuzione, il datapath, che nella
  Saranno probabilmente disponibili appunti simili anche                                sua unità di controllo.
  per i corsi del quarto anno di Microelettronica Digitale e                            L'elettronica digitale, però, prevede anche
  Sistemi Elettronici a Basso Consumo.                                                  la possibilità di utilizzare macchine come
                                                                                        quelle che abbiamo imparato a progettare,
  Slide modificate da Giorgio Fissore                                                   ma progettate da altri, con cui eseguire
  Disponibili in centro stampa                                                          una grandissima varietà di algoritmi.

28/9/2012                                MZ-ESD                               L12/ 1

                     Microcontroller systems

                                                                                       Un sistema a microcontrollore (uC) si
                l   Nearly any computing system other                                 differenzia nettamente da un
                     than a general purpose computer                                   microprocessore (uP), e viene oggi chiamato
                l   Microcontroller systems are often                                 sistema embedded: un sistema integrato in
                     called embedded systems                                           un certo ambiente che riceve dei segnali
                                                                                       dall'esterno ed esegue un algoritmo su questi
                l   A computing system, embedded                                      dati che gli arrivano; va poi a produrre degli
                     within a larger system, and repeatedly                            effetti esterni.
                     performing a specific task (“the
                     application”)

28/9/2012                                MZ-ESD                               L12/ 2

                       Embedded Systems

                                     Environment

                                      Information
                 Sensors                                          Actuators
                                      Processing

            • Environment to Environment
            • Sensors + Information Processing + Actuators
                                                                  Mod by Giorgio Fissore
28/9/2012                                MZ-ESD                               L12/ 3

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                             2 di 334
N 1230 ELETTRONICA DEI SISTEMI DIGITALI DI FISSORE GIORGIO - Appunti Universitari Online
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                            3 di 334

                              Embedded Systems
       ✦      A product that uses one or more microcontrollers
            as controller(s). Also called embedded products.
       ✦      End users are interested in the functionality of the
            product, not the microcontroller itself.
       ✦      Cell phones, home security systems, and modern
            automobiles are examples of embedded products.

28/9/2012                                          MZ-ESD                     L12/ 4

                                   An Example
                                                                                       Es. di sistemi embedded in una macchina:
                   q   More than 30% of a car cost is in                              centralina del motore
                        Electronics                                                    centralina del sistema di condizionamento
                                                                                       centralina del controllo dei finestrini
                                                                                       abs,...

28/9/2012                                          MZ-ESD                     L12/ 5

            Embedded systems Applications
  Anti-lock brakes            Modems
  Auto-focus cameras          MPEG decoders
  Automatic teller machines   Network cards
  Automatic toll systems      Network switches/routers
  Automatic transmission      On-board navigation
  Avionic systems             Pagers
  Battery chargers            Photocopiers
  Camcorders                  Point-of-sale systems
  Cell phones                 Portable video games
  Cell-phone base stations    Printers
  Cordless phones             Satellite phones
  Cruise control              Scanners
  Curbside check-in systems   Smart ovens/dishwashers
  Digital cameras             Speech recognizers
  Disk drives                 Stereo systems
  Electronic card readers     Teleconferencing systems
  Electronic instruments      Televisions
  Electronic toys/games       Temperature controllers
  Factory control             Theft tracking systems
  Fax machines                TV set-top boxes
  Fingerprint identifiers     VCR’s, DVD players
  Home security systems       Video game consoles
  Life-support systems        Video phones
  Medical testing systems     Washers and dryers

            And the list goes on and on …                         Mod by Giorgio Fissore
28/9/2012                                          MZ-ESD                     L12/ 6

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                            3 di 334
N 1230 ELETTRONICA DEI SISTEMI DIGITALI DI FISSORE GIORGIO - Appunti Universitari Online
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                            4 di 334

                     The Computer Market

28/9/2012                                MZ-ESD                               L12/ 7

                                                                             La maggior parte dei sistemi embedded sono
        ES: Programming languages used -programmati in C (~60% delle applicazioni)
                                                                             -programmati in C++ (~24%)
                                                                             >>> l'84% dei sistemi embedded viene
                                                                             programmato in C/C++
                                                                             >>> appena il 5% viene programmato in assembler
                                                                             (e probabilmente da vecchi elettronici)
                                                                             >>> nessuno si sognerebbe invece di
                                                                             programmare un embedded in java: questo
                                                                             linguaggio di programmazione infatti è progettato
                                                                             per girare dappertutto, ma non è assolutamente
                                                                             ottimizzato per niente!!
                                                                             >>> il motivo per cui si progetta in C/C++ è che
                                                                             questi due linguaggi vanno praticamente alla
                                                                             stessa velocità dell'assembler!!
                                                                             >> la filosofia di progetto è: fai tutto in C; poi se c'è
28/9/2012
                                                                             qualche punto particolarmente critico, prova a
                                         MZ-ESD                                L12/ 8
                                                                             limare con l'assembler

                              Moore’s Law

        q In 1965 Intel co-founder Gordon Moore
            predicted that IC transistor capacity
            would double every 18 months

                                                                  Mod by Giorgio Fissore
28/9/2012                                MZ-ESD                               L12/ 9

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                            4 di 334
N 1230 ELETTRONICA DEI SISTEMI DIGITALI DI FISSORE GIORGIO - Appunti Universitari Online
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                            5 di 334

                  Design Productivity Gap

                                           Old figures but tendency still valid
28/9/2012                                MZ-ESD                               L12/ 10

                  Traditional Design Flow

28/9/2012                                MZ-ESD                               L12/ 11

Problems with the Traditional Design Flow

            q Lackof a unified hardware-software
               Framework
                 § Hard to verify the entire system
                 § Incompatibilities at the HW/SW boundary
            q “Prejudiced”           definition of the
               partitions
                 § Sub-optimal design
                 § Any change in the partitioning may require
                    considerable redesign efforts (negative
                    impact on the time-to-market)

                                                                  Mod by Giorgio Fissore
28/9/2012                                MZ-ESD                               L12/ 12

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                            5 di 334
N 1230 ELETTRONICA DEI SISTEMI DIGITALI DI FISSORE GIORGIO - Appunti Universitari Online
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                           6 di 334

      Sub-optimal vs. optimal Architecture

28/9/2012                                MZ-ESD                               L12/ 13

               Typical Embedded System
                                                                                    La cache non è presente in molti uC

                                                                                    Caratteristica tipica dei uC (dei sistemi
                                                                                    embedded), che lo differenzia nettamente da
                                                                                    un uP, è la presenza di svariate periferiche!

28/9/2012                                MZ-ESD                               L12/ 14

              What is a Microprocessor ?
                                                                                    Se si prende un uP così com'è, questo non è
            Pentium 4 microphotograph                                               in grado di fare assolutamente nulla, ma
                                                      All building units of         bisogna costruirgli un sistema intorno.
                                                      the processor are             Se si guarda un uC invece è presente la
                                                      integrated on a single        memoria, gli I/O...
                                                      chip while no
                                                      peripheral block is
                                                      integrated inside!!

                                                                  Mod by Giorgio Fissore
28/9/2012                                MZ-ESD                               L12/ 15

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                           6 di 334
N 1230 ELETTRONICA DEI SISTEMI DIGITALI DI FISSORE GIORGIO - Appunti Universitari Online
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                                   7 di 334

                             Microprocessor
                                                                                           La prima caratteristica che caratterizza un uP,
        § A processor implemented on a single integrated circuit                          è il suo parallelismo dei dati; partito da 4 bit,
           (IC). Peripheral chips are needed to construct a
           product.                                                                        ora arrivato a 64 bit.
        § A microcomputer is a computer that uses a                                       >> da questo dipende la precisione dei dati al
           microprocessor as its CPU (such as today’s                                      suo interno.
           desktop).
        – Classifications: word length (number of bits that a
           microprocessor can manipulate in one operation).
              » 4-bit (intel 4004,1971), 8-bit, 16-bit, 32-bit, 64-bit.
        – Limitations:
              » Requires external memory to execute programs;
              » Peripheral chips are needed to interface with I/O devices
              » Glue logic (decoders, buffers) is needed to interconnect
                external memory and peripheral interface chips with the
                microprocessor.

28/9/2012                                 MZ-ESD                                 L12/ 16

                      Microprocessor (MPU)
                                                                                   DataPath, nel caso di un uP è una semplice
                                                                                   ALU.
                                                   w MPU (CPU)                    Più un insieme di registri macchina che
                                                     n   Read instructions        servono per fare le operazioni.
                                                     n   Process binary data

                                                                                    uP: solo ALU, Registri e CU; non è presente
                                                                                    nulla per interagire con l'esterno. (anche ad es
                                                                                    un'interfaccia seriale,...)

28/9/2012                                 MZ-ESD                                 L12/ 17

            Processor (Central Processing Unit)
  q Datapath:
                                                                               Un'altra cosa che distingue uP e uC è la
        § Register file: a register is a storage location within the CPU.
                                                                               frequenza operativa del processore:
        § Arithmetic Logic Unit (ALU):perform all the arithmetic computations dell'ordine dei GHz negli attuali uP, fino
             and logic evaluations.                                                        alle decine di MHz nei uC.
  q Control Unit:
        § Decodes and monitors the execution of instructions and coordinate
             the operations. The system clock synchronizes the activities of the
             CPU, which are measured by clock cycles. (GHz)
        § Maintain 2 registers:
              – PC: keeps track of the address of the next instruction to be executed
              – Status Register: flags the instruction execution result Mod by Giorgio Fissore
28/9/2012                                 MZ-ESD                                 L12/ 18

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                                   7 di 334
N 1230 ELETTRONICA DEI SISTEMI DIGITALI DI FISSORE GIORGIO - Appunti Universitari Online
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                           8 di 334

                 Inside the Microprocessor

                                                      •The CPU executed the
                                                      program instructions
                                                      •ALU performs
                                                      arithmetic and logic
                                                      operations
                                                      •The ID tells the ALU
                                                      what to do with the data
                                                      •PC is a special register
                                                      that tells the CPU
 General Purpose                                      where to get the next
 registers used to                                    instruction
 store useful info
                                                      •PC, AR and DR are
                                                      special registers

28/9/2012                                MZ-ESD                               L12/ 19

            Microprocessor Basic Operation
      q    Program (instructions) and Data are stored in Memory
      q    Each instruction is read (fetched) from memory,
            interpreted (decoded), and executed
            § Arithmetic Logic Unit (ALU) performs operations on data
            § Data is transferred (register, memory, I/O)
      q    Program Counter (PC) indicates current location of
            program in Memory and is automatically incremented after
            each instruction                                                       Il funzionamento come già visto avviene
      q    Each instruction can take several clock cycles                         attraverso le tre fasi in successione di:
                                          Fetch
                                                                                   -fetch, cerco cosa devo fare
                                                                                   -decode: capisco cosa devo fare
                                                   Decode                          -execute: eseguo l'operazione.
                                                                                   E' questo il flusso base di operazioni di un uP.
                                        Execute                                    Questo vale anche per un sistema a uC.
28/9/2012                                MZ-ESD                               L12/ 20

                                   Memory

                                                   w Storage Device
                                                        n   Addresses
                                                        n   Registers
                                                   w Major Categories
                                                        n   Read/Write Memory
                                                             (R/W)
                                                        n   Read-only-Memory
                                                             (ROM)

                       D7               D0
                                                                  Mod by Giorgio Fissore
28/9/2012                                MZ-ESD                               L12/ X

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                           8 di 334
N 1230 ELETTRONICA DEI SISTEMI DIGITALI DI FISSORE GIORGIO - Appunti Universitari Online
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                              9 di 334

                                   Memory
        q   Semiconductor memory, magnetic, optical memory.
        q   Semiconductor memory:
             § Random access memory (RAM):volatile
                 – Dynamic RAM (DRAM): periodic refresh operations to
                   maintain the stored information. Every a few milliseconds
                   to over a hundred ms.
                 – Static RAM (SRAM):no need to refresh. More transistors
                   are used to hold one bit information.
             § Read-only memory (ROM): nonvolatile.
                 – MROM: mask-programed ROM, programmed when
                   being manufactured.
                 – PROM: programmable ROM, one-time programmable
                   ROM using PROM programmer/burner by end users.
                 – EPROM: erasable PROM, strong ultraviolet light,
                   erasable in bulk.
                 – EEPROM: electrically EPROM, erased by electrical
                   signals and reprogrammed. Individual location.
                 – Flash memory: take advantages of EPROM and
                   EEPROM
28/9/2012                                MZ-ESD                                L12/ X

                                I/O devices
                                                                                  Come ingressi si hanno pulsanti, tastiere,..
        q   Input device                                                         come uscite generalmente schermi o led che si
             § Allow users to enter data/programs into the                       accendono e si spengono.
                computer so that computation can be performed.
             § Examples:
                ✦   Switches and Keypads
                ✦   Provide binary information to the MPU
        q   Output device
             § Display results of computation so that users can
                read them and equipment can be controlled.
             § Examples:
                 ✦ LEDs and LCDs

                 ✦ Receive binary information from the MPU

28/9/2012                                MZ-ESD                                L12/ 21

             Microprocessor-Based Systems
                                                                                         In un sistema a uP, ci sono gli I/O visti
                                                                                         prima collegati dai bus (posizionate in
                                                                                         genere su una scheda), ma le varie parti
                                                                                         sono tutte separate!

                                                                  Mod by Giorgio Fissore
28/9/2012                                MZ-ESD                                L12/ 22

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                              9 di 334
N 1230 ELETTRONICA DEI SISTEMI DIGITALI DI FISSORE GIORGIO - Appunti Universitari Online
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                        10 di 334

                    Microprocessor Architecture

        w The MPU communicates with Memory
           and I/O using the System Bus
               n   Address bus
                    l   Unidirectional
                    l   Memory and I/O Addresses
               n   Data bus
                    l   Bidirectional
                    l   Transfers Binary Data and Instructions
               n   Control lines
                    l   Read and Write timing signals

28/9/2012                                 MZ-ESD                              L12/ X

             Example Microprocessor System

28/9/2012                                 MZ-ESD                              L12/ X

        What is a Microcomputer System ?
                                                                              Un uC, invece ha qualcosa in più.
            q It
                is a computing system based on                                Ha al suo interno un processore, la CPU, ma oltre
               microcontroller.                                               ciò, è anche presente tutta la parte di memoria
                                                                              (rom e ram); il bus di sistema è interno
                                                                              all'integrato. Vi è anche in esso tutta la gestione
                                                                              del clk, tutta la gestione delle periferiche, la
                                                                              gestione dei buffer e dei livelli elettrici per
                                                                              comunicare con l'esterno..
                                                                              >> tutti i circuiti che servono per gestire le
                                                                              periferiche sono embedded dentro il sistema
                                                                              >> un uC è un sistema single chip >> con un solo
                                                                              integrato posso gestire tutto il sistema.
                                                                              (buffer e convertitori, gestione dei bus,
                                                                              generazione del clk, gestione della potenza)
                                                                  Mod by Giorgio Fissore
28/9/2012                                 MZ-ESD                              L12/ 23

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                        10 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                         11 di 334

                         Microcontroller System
        q The buffers and converters condition I/O
           signal levels if necessary
        q The bus is a group of signals (data,
           address, control signal) with a common
           purpose.
        q The clock circuit generates a fixed-
           frequency, timing signal for the entire
           system.
        q The power supply converts a raw power
                                                      Questa parte della gestione della potenza è molto
           source into the DC voltage (nominally 5 / critica: infatti magari il uC lavora a 2.7 V, ma deve
           3.3 / 2.7 / 1.8 V) required by the system.
                                                                             generare segnali esterni a 5 V,..
                                                                             >> ha una parte significativa di eln analogica per
28/9/2012                                  MZ-ESD
                                                                             gestire
                                                                               L12/ 24
                                                                                       le varie tensioni con cui andiamo a
                                                                             lavorare.

                               Microcontrollers
    w Embedded Systems
            n   Operations managed behind the scenes by
                 a microcontroller
    w Microcontroller (MCU)
            n   An integrated electronic computing device
                 that includes three major components on a
                 single chip
                 l   Microprocessor (MPU)
                 l   Memory
                 l   I/O (Input/Output) ports
28/9/2012                                  MZ-ESD                             L12/ 25

                               Microcontrollers

        w Support Devices
                 n   Timers
                 n   A/D converter
                 n   Serial I/O
        w Common communication lines
                 n   System Bus

                                                                  Mod by Giorgio Fissore
28/9/2012                                  MZ-ESD                             L12/ 26

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                         11 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                            12 di 334

                              Block Diagram

28/9/2012                                MZ-ESD                               L12/ 27

                  Microcontroller Organization

28/9/2012                                MZ-ESD                               L12/ 28

            Microcontroller Functional Units
            q   CPU: Central Processing Unit
                 (4,8,16,32 bit data bus)
            q   ROM: Read Only Memory (Firmware)
            q   RAM: Random Access Memory
                 (Register File, Processor Stack, Temporary data)
            q   PIO: Parallel I/O (relays, sensors)
            q   INT: Interrupt Inputs
                 (external/internal sources)
            q   UART: Universal Asynchronous Receiver
                 Transmitter (e.g. RS232)
            q   GPT: General Purpose Timer
                 (optional event counter)
            q   PWM: Pulse Width Modulator (motor controller)
            q   WDT: Watch Dog Timer (automatic reset)
            q   AIO: Analog I/O (ADC & DAC)
                                                                  Mod by Giorgio Fissore
28/9/2012                                MZ-ESD                               L12/ 29

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                            12 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                     13 di 334

                  Memory basic concepts
  q   Digital data is stored in the form of binary numbers, however it    Il uC ha bisogno di una memoria interna per
       is often represented using the hexadecimal numbering system.        salvare i suoi dati,..
   q The bit is the smallest digital unit, and is either 1 or 0.          Qual'è l'unità base con cui si lavora: di solito è il
   q A byte is defined to be 8 bits.                                      byte l'elemento più piccolo che può essere
   q A word varies from processor to processor and can be 8, 16, 32       indirizzato dal uC.
       or more bits.                                                       >> si può poi cambiare il singolo bit, ma si
   q Normally, the byte is the smallest addressable unit; however,        legge cmq il byte.
       it is possible to address individual bits in I/O registers.
                                                                           >> se lavoro con un uC a 16 bit, ogni volta che
   q Freescale convention: binary number are prefixed by % and
                                                                           leggo, accedo a due locazioni consecutive:
       hexadecimal numbers by $
                                                                           la prima volta accedo a locazione zero, la volta
   q Big-Endian: using lowest address for most significant byte (used
       by Motorola/Freescale)                                              dopo alla locazione due, poi quattro,..
   q Little-Endian: using lowest address for least significant byte
                                                                           Leggendo due byte per volta, è possibile quindi
       (used by Intel microcomputers)                                      scegliere se mettere il byte più significativo
                                                                           nell'indirizzo più basso o più alto.
28/9/2012                                                              L12/ 30
                                         MZ-ESD
                                                                           >> esistono quindi due mondi differenti, adottati
                                                                           rispettivamente dalla freescale (di motorola), e
                                                                           dal mondo intel che generano notevoli problemi
                                                                           quando si vuole passare da un mondo all'altro.
                  Memory basic concepts                                    -Noi lavoreremo con mondo freescale, in cui
                                                                           MSB è posizionato nell'indirizzo più basso.

28/9/2012                                MZ-ESD                               L12/ 31

                            Memory Types

   The main types of semiconductor memory are:

        ROM – Read Only Memory
        RAM – Random Access Memory
        EPROM – Erasable Programmable Read Only
         Memory                              Il vantaggio della EEPROM è che posso andare a
        EEPROM/FLASH – Electrically Erasable modificare ogni singola cella per volta.
         Programmable Read Only Memory       >> la flash è molto più compatta, ma posso
                                                                        programmarla solo a pagine o settori

                                                                  Mod by Giorgio Fissore
28/9/2012                                MZ-ESD                               L12/ 32

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                     13 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                        14 di 334

                                    The Bus

        q   The bus provides the communication infrastructure among
             the various components of the system
        q   Data bus carries the information being transmitted/received.
        q   Address bus tells where the information is being
             transferred to/from.
        q   Control bus specifies when the information transfer take        Control bus: viaggiano su di esso l'insieme di
             place by coordinating the access to the data bus and the        segnali di controllo necessari per il
             address bus, and directs the data from/to the specific          trasferimento delle informazioni (es dicono se
             components.                                                     lettura/scrittura, se il dispositivo è pronto o
                                                                             meno per ricevere dati,...)

28/9/2012                                 MZ-ESD                              L12/ 33

                   Computer Architectures
                    (complementary stuff)
        w Princeton (Von Neumann) versus
           Harvard Architecture
        w CISC versus RISC processors
        w Microprocessors and Microcontrollers

28/9/2012                                 MZ-ESD                              L12/ X

                         Computer Concepts
        q Computer:
             § Hardware:
                 – Processor: “brain”, CPU
                        Datapath: registers and ALU
                        Control unit: hardware instrucion logic.
                 – Memory: place to store software programs and
                   data
                 – I/O devices: enter data/programs into the
                   computer/display outputs
             § Software: programs
                 – A program is a set of instructions that the
                   computer hardware can execute.
                                                                  Mod by Giorgio Fissore
28/9/2012                                 MZ-ESD                              L12/ X

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                        14 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                     15 di 334

                           Computer Organization

28/9/2012                                     MZ-ESD                                   L12/ X

                                    Software
        q Programs. A program is a set of
           instructions that can be executed by the
           computer hardware.
        q Machine instructions:
             – A sequence of binary digits that can be executed by the processor
               e.g: 0001100000000110 (Accumulator A
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                              16 di 334

                          High-level languages
- Syntax of a high-level language is similar to English, (C/C++,
  Java, Fortran, PASCAL…)
- A translator is required to translate the program written in a
  high-level language -- done by a compiler
- High-level languages allow the user to work on the program
  logic
  at higher level.

     Source Code
                 A program written in assembly or high-level language

     Object Code
                 The output of an assembler or compiler

28/9/2012                                   MZ-ESD                                  L12/ X

                                      Software
        w Machine Language
            n   Binary Instructions
            n   Difficult to decipher and write
                   l   Error-prone
            n   All programs converted into machine
                 language for execution

        Instruction Hex Mnemonic             Description            Processor
        10000000          80   ADD B         Add reg B to Acc       Intel 8085
        00101000          28   ADD A, R0 Add Reg R0 to Acc Intel 8051
        00011011          1B   ABA           Add Acc A and B        Motorola 6811

28/9/2012                                   MZ-ESD                                  L12/ X

                                      Software

        w Assembly Language
            n   Machine instructions represented in
                 mnemonics
            n   One-to-one correspondence
            n   Efficient execution and use of memory
            n   Machine-specific

                                                                   Mod by Giorgio Fissore
28/9/2012                                   MZ-ESD                                  L12/ X

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                              16 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                            17 di 334

                                        Software

        w High-Level Languages
             n    BASIC, C, and C++
             n    Written in statements of spoken languages
             n    Machine independent
             n    Easy to write and troubleshoot
             n    Larger memory and less efficient execution

28/9/2012                                   MZ-ESD                            L12/ X

                             Data Format (8-bit)

            w Unsigned Integers
              n   All eight bits represent the magnitude of a
                   number
                    l   Bit7 to Bit0
              n   Range 00H to FFH (010 to 25510)

28/9/2012                                   MZ-ESD                            L12/ X

                             Data Format (8-bit)

        w Signed Integers
             n    2's Complement
                   l   Bit 7 is sign bit
             n    Positive numbers: 00H to 7FH (010 to 12710)
             n    Negative numbers: 80H to FFH (-110 to
                   -12810)

                                                                  Mod by Giorgio Fissore
28/9/2012                                   MZ-ESD                            L12/ X

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                            17 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                            18 di 334

                          Data Format (8-bit)

        w Binary Coded Decimal Numbers (BCD)
            n   8 bits of a number divided into groups of
                 four
                 l   Each group represents a decimal digit from 0 to
                      9
            n   AH through FH are invalid
            n   Example: 0010 0101BCD = 2510

28/9/2012                                MZ-ESD                               L12/ X

                          Data Format (8-bit)

        w American Standard Code for
           Information Interchange (ASCII)
            n   Seven-bit alphanumeric code with 128
                 combinations (00H to 7FH)
            n   Represents English alphabet, decimal
                 digits from 0 to 9, symbols, and commands

28/9/2012                                MZ-ESD                               L12/ X

                        MPU-Based Systems

        w System hardware
            n   Discrete components
                 l   Microprocessor, Memory, and I/O
            n   Components connected by buses
                 l   Address, Data, and Control
        w System software
            n   A group of programs that monitors the
                 functions of the entire system

                                                                  Mod by Giorgio Fissore
28/9/2012                                MZ-ESD                               L12/ X

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                            18 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                            19 di 334

                    MPU-Based Time
                 and Temperature System

28/9/2012                                MZ-ESD                               L12/ X

                     MCU-Based Systems

        w Includes microprocessor, memory, I/O
           ports, and support devices (such as
           timers) on a single semiconductor chip
        w Buses are generally not available to a
           system designer
        w I/O ports are generally multiplexed and
           can be programmed to perform different
           functions

28/9/2012                                MZ-ESD                               L12/ X

                       MCU-Based Time
                    and Temperature System

                                                                  Mod by Giorgio Fissore
28/9/2012                                MZ-ESD                               L12/ X

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                            19 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                              20 di 334

  9S12 Hardware Overview, Subsystems, and
              Memory System

 Slide modificate da Giorgio Fissore
 Disponibili in centro stampa

1/10/2012                                         MZ-ESD                                    L13/ 1

                                           Overview

                            • 9S12 hardware overview
                            • Subsystems
                            • Memory System

1/10/2012                                         MZ-ESD                                    L13/ 2
MC9S12E128A Block Diagram

                                                                   •   Processor CPU12
                                                                   •   xx Kbytes Flash EEPROM
                                                                   •   yy Kbytes RAM
                                                                   •   zz bytes      EEPROM
                                                                   •   PAD	
A/D 16 channels 10 bits
                                                                   •   PTT	
 Timer
                                                                   •   PTS	
Serial SCI, SPI, 2 I/O
                                                                   •   PTU	
4 PWM, 4 I/O
                                                                   •   PTA 	
Address/Data
                                                                   •   PTB	
Address/Data
                                                                   •   PTE	
Control
                                                                   •   PTK Extended Address
                                                                   •   BDI	
 Debug
                                                                   •
                                                                   •
                                                                   •

                                                                           Mod by Giorgio Fissore
1/10/2012                                         MZ-ESD                                    L13/ 3

             Centro stampa Copysprinter – Stampa Autorizzata dall’autore                              20 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                               21 di 334

                                         9S12
  q    A simple processor like the 9S12 has four major components:
         § The control unit (CU). The instruction register (IR) contains
            the op code for the current instruction. Most 9S12 op codes                  EAR: registro che contiene l'indirizzo a cui
            are 8 bits wide, but some are 16 bits.                                       puntare in mem per prendere il dato (dopo
         § The arithmetic logic unit (ALU)                                              averlo calcolato si salva qui)
         § Registers. Accumulator, pointer and program counter (PC).
         § The bus interface unit (BIU). It reads data from the bus
            during a read cycle, and writes data onto the bus during a                   3 bus: dati, indirizzo, R/W
            write cycle.The effective address register (EAR) contains the
            data address for the current instruction.

                                                                                         Una sola memoria per indirizzi e dati
                                                      16

1/10/2012                                   MZ-ESD                              L13/ 4

                                           BIU
   q    Core of the BIU is the instruction queue, used to buffer program                  Pre-fetching: si cercano in anticipo le
         information.                                                                      istruzioni seguenti ogni volta che la
   q    The 9S12 BIU reads the op code, then it reads the operand, and                    memoria è libera, così non devo quasi mai
         finally it reads and writes memory data as required.
                                                                                           cercare in memoria le istruzioni richieste,
   q    The instruction queue is a hardware first-in-first-out queue, placed
         between the BIU and the CU.                                                       perchè già pronte.
   q    Queue logic fetches program information and positions it for
         execution, but instructions are executed sequentially.                           Qui il BIU ha una coda di tre parole da 16
   q    The queue can hold up to three 16-bit values.                                    bit che funziona come una FIFO per le
   q    Writes from the processor to memory do not pass through the queue.               istruzioni pre-fetchate
   q    Using a queue allows the 9S12 to fetch the op code and operands of
         the next instruction while it is executing the current instruction.

1/10/2012                                                                       L13/ 5
                                            MZ-ESD
                                                                                         L'unico problema è che le macchine così
                                                                                         costruite sono più difficili da debuggare, in
                                                                                         quanto non basta mettersi sul bus che
                                                                                         unisce uP e memoria per vedere in ogni
                      9S12 Instruction Queue                                             istante cosa sta facendo la macchina.
                                                                                         Ora, con cache e pre-fetch non ho modo di
                                                                                         sapere cosa sto facendo real time.

                                                                                          Devo quindi aggiungere un modulo HW che
                                                                                          mi dica cosa sto facendo:
                                                                                          Remote Background Debug.
                                                                                          >> fondamentale, è lui che ci dice, parlando
                                                                                          con un programma su PC cosa si sta
 ✓ This diagram shows the CPU12 three stage instruction                                   facendo
   queue with an additional temp or prefetch stage.
 ✓ The queue is provided so that the CPU can immediately
   begin instruction execution as soon as the current
   instruction completes.
 ✓ The data bus supplies the opcodes into the queue as well
   as the data path to the execution unit.
                                                                     Mod by Giorgio Fissore
1/10/2012                                   MZ-ESD                              L13/ 6

       Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                               21 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                               22 di 334
                                                                                         Nel caso in cui si abbassasse la tensione devo
Clock and Reset Generation Block (CRG)                                                   resettare in maniera particolare.

                                                                                        Blocco per la generazione di CLK e Reset
                                                                                        estremamente complesso.

                                                                                        5 modi diversi per resettare, tra gli altri, un
                                                                                        reset per lavorare anche se il clk si inchioda,
                                                                                        con un clk = 1 MHz

                                                                                        3 clk diversi!!!

1/10/2012
                                  Moltiplicatore, o divisore, di frequenza;
                                                                      L13/ 7
                                                                             impiega però
                                         MZ-ESD
                                  parecchio tempo per agganciarsi alla frequenza richiesta
                               possiamo prendere
                               il clk da qui o dal pll
Clock and Reset Generation Block (CRG)
 Features (from data sheets)

 • Phase-locked loop (PLL) frequency multiplier
     — Reference divider
     — Automatic bandwidth control mode for low-jitter operation
     — Automatic frequency lock detector
     — CPU interrupt on entry or exit from locked condition
     — Self-clock mode in absence of reference clock
 • System clock generator
     — Clock quality check
     — Clock switch for either oscillator- or PLL-based system clocks
     — User selectable disabling of clocks during wait mode for reduced power
     consumption
 • Computer operating properly (COP) watchdog timer with time-out clear window
 • System reset generation from the following possible sources:
     — Power-on reset
     — Low voltage reset (when available)
     — COP reset
     — Loss of clock reset
     — External pin reset
 • Real-time interrupt (RTI)
1/10/2012                                MZ-ESD                                L13/ 8

Clock and Reset Generation Block (CRG)
    q   CRG generates the clock signals required by the instruction
         execution and all peripheral operations.
    q   The clock signal has the form of square waveform.
    q   Crystal oscillators are often used to generate clock signals.
    q   The crystal oscillator output is sinusoidal wave that is squared up
         internally before it can be used.
    q   The CRG block also has a PLL circuit that can multiply the
         frequency of the incoming clock signal.
    q   The CRG can also accept oscillator output (square waveform)
         directly.
    q   The XCLKS signal must be tied low (for MC9S12DP256B) in order
         to use external clock signal.

                                                                  Mod by Giorgio Fissore
1/10/2012                                MZ-ESD                                L13/ 9

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                               22 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                                        23 di 334

                        Choice of Clock Source
     q   The user can choose between using the external crystal or oscillator to                       Posso generare il clk:
          produce the clock signal.                                                                     -a partire da un clk esterno
     q   The external crystal is connected between the EXTAL and XTAL pins                             -dal clk esterno, ma passandolo dentro al
          and needs an on-chip oscillator circuitry to square it up.                                    pll
     q   The external clock source provided by the oscillator is connected to the                      -interno,...
          EXTAL pin and has a 2.5V peak-to-peak magnitude for D family.
                                                                                                        (è molto importante avere molta scelta su
     q   The XCLKS signal must be grounded to select the external clock
          signal.
                                                                                                        come poter programmare il clk).
     q   The output from the OSC module may bypass or go through the PLL
          circuit.
     q   The PLL circuit has the capability to multiply incoming signal frequency
          and stabilize its output signal frequency.
     q   Either the OSCCLK or the PLLCLK can be chosen as the SYSCLK
          which will be divided by 2 to derive the bus clock to control the
          instruction execution and peripheral operation.
1/10/2012                                       MZ-ESD                                     L13/ X

                        Choice of Clock Source

1/10/2012                                       MZ-ESD                                     L13/ 10

                                Available Clocks
q    CGC creates the clocks used in the MCU. The gating condition placed on top of the                Abbiamo due scelte sul clk:
      individual clock gates indicates the dependencies of different modes (stop, wait)

q    Bus Clock is used by
          § Peripherals (some peripheral modules also use the oscillator clock).
          § The memory blocks.
          § Bus clock is used to generate the clock visible at the ECLK pin.

q    Core clock signal is the clock for the CPU.                                                    Questo secondo clk può raggiungere il doppio
          § It is twice the bus clock but a CPU cycle corresponds to one bus clock.
                                                                                                     della frequenza del bus clk, poichè essendo
q    PLL clock mode is selected with PLLSEL bit.                                                    più interno è possibile spingere di più
          § When selected, the PLL output clock drives SYSCLK for the main system including
             the CPU and peripherals.
          § The PLL cannot be turned off by clearing the PLLON bit, if the PLL clock is selected.
          § When PLLSEL is changed, it takes a maximum of 4 OSCCLK plus 4 PLLCLK cycles
             to make the transition.
          § During the transition, all clocks freeze and CPU activity ceases

                                                                         Mod by Giorgio Fissore
1/10/2012                                       MZ-ESD                                     L13/ 11

      Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                                        23 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                               24 di 334

                  Phase Locked Loop (PLL)

      q    The frequency of the PLLCLK is controlled by registers
            SYNR and REFDY using the following equation:                                  In un PLL il clk si genera partendo da un clk
                                                                                          esterno, moltiplicato per il rapporti tra due
                                             (SYNR + 1)
                     PLLCLK = 2 × OSCCLK × -----------------------                        numeri scritti in due registri.
                                             (REFDV + 1)                                  >> per far funzionare il blocco del PLL devo
                                                                                          prima programmarlo.

1/10/2012                                  MZ-ESD                               L13/ 12

                  Phase Locked Loop (PLL)

  Selection of
  PLL for clock
  generation is
  controlled by
  the CRGSEL
  register.

1/10/2012                                  MZ-ESD                               L13/ 13

                  Phase Locked Loop (PLL)

  PLL circuit
  is also
  controlled
  by the
  PLLCTL
  register.

                                                                     Mod by Giorgio Fissore
1/10/2012                                  MZ-ESD                               L13/ X

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                               24 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                                               25 di 334

                    Phase Locked Loop (PLL)
 •    Example There is a system that derives its bus clock from the PLL                                  Impareremo qualche istruzione assembler,
      circuit and an external clock of 8 MHz is selected. The desired bus
      clock is 24 MHz. Write an instruction sequence to perform the desired                              poichè in debug mode, si vede proprio il
      configuration.                                                                                     codice assembler.
 •    Solution
       § The SYSCLK frequency is 48 MHz.
       § The frequency of OSCCLK is 8 MHz.                                                              movb #[byte],[address] = "muovi il [byte] nel
       § 48 MHz = 2 × 8 MHz × [SYNR + 1] / [REFDV + 1]                                                  registro [address]
            – One solution is to set SYNR and REFDV to 2 and 0,
              respectively.

                  movb #2,SYNR             ; set SYNR to 2
                  movb #0,REFDV            ; set REFDV to 0
                  movb #$80,CRGSEL         ; enable PLL, keep SYSCLK running in wait mode,
                                           ; keep RTI, COP, PLL & core running in wait mode
                  movb #$60,PLLCTL         ; disable clock monitor, enable PLL, set automatic
                                           ; bandwidth control, disable RTI & COP in pseudo stop

                • In addition, the XCLKS pin must be grounded to select oscillator as
                   clock source.

1/10/2012                                    MZ-ESD                                            L13/ 14

                    Phase Locked Loop (PLL)
•    Example There is a system that uses a 4 MHz crystal oscillator to
     derive a 24 MHz bus clock. Write an instruction sequence to perform
     the required configuration.
•    Solution The OSCCLK and PLLCLK frequencies are 4 MHz and 48
     MHz, respectively.
      § 48 MHz = 2 × 4 MHz × [SYNR + 1] / [REFDV + 1]
      § One solution is to set SYNR and REFDV to 5 and 0, respectively.

                   movb    #5,SYNR         ; set SYNR to 5
                   movb    #0,REFDV        ; set REFDV to 0
                   movb    #$80,CRGSEL     ; enable PLL, keep SYSCLK running in wait mode,
                                           ; keep RTI, COP, PLL & core running in wait mode
                   movb    #$60,PLLCTL     ; disable clock monitor, enable PLL, set automatic
                                           ; bandwidth control, disable RTI & COP in pseudo stop

            • The XCLKS pin must be pulled to high to select external crystal to
            generate clock signals.

1/10/2012                                    MZ-ESD                                            L13/ X

                     CPU12, register's model

                                                   • 8 bits data registers: A et B
                                                   • A – B : 16 bits : D                                   Nel cuore, la CPU, ci sono questi registri:
                                                                                                           -16 bit per i dati
                                                                                                           -16 bit per puntare ai registri
                                                   • 16 bits pointers registers :
                                                                                                           -16 bit per puntare lo stack
                                                   	
IX et IY
                                                                                                           -16 bit per puntare il program counter (PC)
                                                   • Stack Pointer : SP
                                                   • Program Counter Register :
                                                     PC
                                                   • Flags CCR : S X H I N Z V C

                                                                          Mod by Giorgio Fissore
1/10/2012                                    MZ-ESD                                            L13/ 15

     Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                                               25 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                             26 di 334

                         Hardware Overview

            •   Timing System
            •   Memory System
            •   Interrupt and Reset System
            •   Serial Communication System
            •   Port System
            •   Data Conversion System

1/10/2012                                MZ-ESD                              L13/ 16

                      Hardware Overview (cont)
                                                                                       In base alle versioni posso scegliere il uC
                                                                                       anche con diversi tagli di memoria
            • Low power consumption - CMOS technology,
            • 16-bit data path (it can be used in 8-bit mode)
            • Different memory configurations:
               – 1..12 K-byte RAM
               – 0.5...4 K-byte EEPROM             qui posso modificare anche la
               – 16..240 K-byte FLASH              singola locazione
            • 8-channel, 16-bit timer, configure each
              channel separately as input or output
            • 16-bit pulse accumulator

1/10/2012                                MZ-ESD                              L13/ 17

                      Hardware Overview (cont)

            • Real-time interrupt capability -
              accomplish operations on recurring
              basis - reminder
            • Serial communications:
                – Serial Communication Interface (SCI)
                   • asynchronous, 2 channels
                – Serial Peripheral Interface (SPI)
                   • synchronous
            • 8-channel, 8-bit analog-to-digital
              converter
                                                                  Mod by Giorgio Fissore
1/10/2012                                MZ-ESD                              L13/ 18

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                             26 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                              27 di 334

                       Hardware Overview (cont)
   • Modes of Operation                                                                I uC possono lavorare in modi differenti; nel
     – Normal                                                                          nostro caso 2;
     – Special (used for debugging single-chip operation,                              -Normal, per il funzionamento normale
       boot-strapping, or security related operations.                                 -Special, usato per funzioni particolari, tipo
       Background debug module BDM is active in this                                   quando uso il BDM (backgroung debug
       mode. The CPU executes a monitor program located                                module), o quando sono in accensione.
       in an on-chip ROM)
   • Configure using some pins at reset                                                Per capire come lavorare si controllano i bit di
   • Normal modes:                                                                     un registro.
     – Normal Single-Chip Mode                                                         NOTA: il PLL è già una periferica
     – Normal Expanded Wide Mode - 16-bit data bus                                     -Register Block: insieme di registri che mi
                                                                                       permettono di comunicare con le periferiche.
     – Normal Expanded Narrow Mode - 8-bit data bus

1/10/2012                                MZ-ESD                              L13/ 19

                    9S12 Subsystems Register Block
            • Register Block
               – 1024-byte memory map collection of registers
               – Registers used to configure uC for specific tasks
                  • turn subsystems “on” and “off”, configure
                    operation
                  • default register settings

            EX:   ATDCTL2          = $0062 ;register offset from base
                  ATD_INI          = $80 ;register mask or value

                  LDAA #ATD_INI
                  STAA ATDCTL2

1/10/2012                                MZ-ESD                              L13/ 20

                        Subsystems Port System
                                                                                       Port system: insieme di porte a 8 bit che
            • Port System                                                              servono per interfacciarsi; possono essere:
               – used to exchange data and control signals with                        -general purpose (le programmo per
                 outside environment                                                   qualsiasi scopo)
               – Port is either an input register, output register, or                 -specific task
                 configurable I/O register
               – Multiple ports
                  • A - H, J general purpose I/O ports in single
                    chip mode, have other functions in expanded
                    mode
                  • S: serial communication, T: timer system,
                    AD: analog-to-digital

                                                                  Mod by Giorgio Fissore
1/10/2012                                MZ-ESD                              L13/ 21

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                              27 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                              28 di 334

                        Subsystems Port System
       • Port related registers:
                                                                                       Ogni porta ha per esempio un:
          – Data Direction Register (DDRx): configures Port
                                                                                       -DDR: per decidere I/O
            as input/output (1: output, 0: input)
                                                                                       -PUCR: decide se attivare Rpu
          – Pull Up Control Register (PUCR): provides built-in
                                                                                       -RDRIV: decide se lavorare a bassa
            pull-up resistor for interface applications
                                                                                       corrente.
          – Reduced Drive of I/O Lines Register (RDRIV):
                                                                                       >>> differenza rispetto a uP
            reduces current drive capability of pin
                                                                                       >>> posso programmare anche i livelli
          – Port E Assignment Register (PEAR):
                                                                                       elettrici del uC, e la gestione degli I/O
                 • provides alternate bus functions in expanded mode
                 • signals used in memory expansion applications

1/10/2012                                MZ-ESD                              L13/ 22

            Registers I/O (some examples...)

1/10/2012                                MZ-ESD                              L13/ 23

The Timing System - Standard Timer Module (TIM)

            • TIM contains 16-bit programmable counter
            • Provides following precision timer functions:
               – Output compare: generate precision output signals
                 such as periodic digital waveforms, pulses, etc.
               – Input capture: measure the characteristics of
                 incoming signals such as frequency, period, duty
                 cycle, pulse length
               – Pulse accumulator: count external events
               – Pulse Width Modulated (PWM) signal generation
                  • PWM not available in some S12 variant

                                                                  Mod by Giorgio Fissore
1/10/2012                                MZ-ESD                              L13/ 24

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                              28 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                            29 di 334
                  9S12: The Memory System

1/10/2012                                MZ-ESD                              L13/ 25

                  9S12: The Memory System

     • Data bus width = memory width = M
     • memory locations = 2addr lines = 2n
     • Memory expressed as length x width
        – 2n x M bits
     • 9S12
        – 16-bit address bus
           • 1st address: %0000_0000_0000_0000 = $0000
           • last address: %1111_1111_1111_1111 = $FFFF
           • 216 locations = 65, 536 locations ~ 64K
        – 16-bit data bus (use 8-bit configuration, too)

1/10/2012                                MZ-ESD                              L13/ 26

                  9S12: The Memory System
       • Memory Technologies:
         – RAM: Random Access Memory
            • volatile: no power, no memory
            • read/write
            • faster access time than ROM
            • temporary data storage during program execution
            • program storage during code development
         – ROM: Read Only Memory
            • nonvolatile
            • read
            • stores instructions and constants
            • byte-erasable EEPROMs, flash EEPROMs
            • program storage in final code version
                                                                  Mod by Giorgio Fissore
1/10/2012                                MZ-ESD                              L13/ 27

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                            29 di 334
Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                           30 di 334
                             9S12 Subsystems
                            The Memory System
  Memory map for the MC9S12C
                                                                                    Siccome la mia macchina è a 16 bit, può
    Registers                                                                       programmare fino a 2'16 bit >> 4 kByte
                                                                                    >> come si fa se si hanno ad es 256 k di flash?
     RAM                                                                            >> organizzo la memoria in pagine da 16 k; poi
                                                                                    ne scelgo una per volta e la carico.
    (E2PROM)                                                                        >> è fondamentale conoscere la mappa della
                                                                                    memoria perchè devo indirizzare quella.

   Flash
 E2PROM

1/10/2012                                MZ-ESD                              L13/ 28

                  9S12 Subsystems Interrupts
                                                                      ISR

  • Break in normal program execution
                                                   fetch     decode
  • Usually higher priority event
                                                                                       -La macchina dovrà gestire anche gli
  • In response to interrupt, 9S12:
                                                         execute                       interrupt esterni;
     – finishes current instruction
                                                                                       -La gestione degli interrupt non è banale e
     – stores key register values                                                      molto importante
     – selects the correct vector to be served in the                                  -E' difficile programmare con gli interrupt
        Interrupt Vector Table                                                         perchè essi sono eventi asincroni.
     – performs an Interrupt Service Routine (ISR)
        specific for that interrupt

1/10/2012                                MZ-ESD                              L13/ 29

                CPU12, Interrupts Vector table

                                                                  Mod by Giorgio Fissore
1/10/2012                                MZ-ESD                              L13/

    Centro stampa Copysprinter – Stampa Autorizzata dall’autore                                                           30 di 334
Puoi anche leggere