sistemes electrÒnics digitals -...

20
EX4: Analysing the PIC16F8XX microcomputer’s family EX4 de Sistemes Electrònics Digitals GRUP: DATA: Descripció de les aportacions realitzades i de les conclusions d’aquest exercici TEMPS D’ESTUDI I DE PREPARACIÓ DE L’EXERCICI: Sessions TGA a l’aula: Sessions TGB al laboratori Sessions TGC fora de l’horari Aquest apartat és obligatori. Si no és present, no es corregeix l’exercici i s’ha de tornar a lliurar Heu d’apuntar tot el temps d’estudi que heu dedicat a l’exercici 1

Upload: ngoliem

Post on 22-Jul-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

EX4: Analysing the PIC16F8XX microcomputer’s family

EX4 de Sistemes Electrònics Digitals

GRUP:

DATA:

Descripció de les aportacions realitzades i de les conclusions d’aquest exercici

TEMPS D’ESTUDI I DE PREPARACIÓ DE L’EXERCICI:

Sessions TGA a l’aula:

Sessions TGB al laboratori

Sessions TGC fora de l’horari

Treball individual

Estudiant 1:

Estudiant 2:

Estudiant 3:

Mitjana de temps total (per estudiant)

Aquest apartat és obligatori. Si no és present, no es corregeix l’exercici i s’ha de tornar a lliurar

Heu d’apuntar tot el temps d’estudi que heu dedicat a l’exercici

1

EPSC – SED: Sistemes Electrònics Digitals

ÍNDEX DE CONTINGUT

Analysing the PIC16F8XX microcomputer’s family................................................................................3

1.1 Description.....................................................................................................................................3

1.2 Objectives......................................................................................................................................3

1.3 Study time:.....................................................................................................................................3

1.4 PIC16F87X central process unit (CPU).........................................................................................3

1.4.1 Architecture...........................................................................................................................3

1.4.2 PIC assembler: RISC instruction set.....................................................................................4

1.5 Visiting microcontroller portals.....................................................................................................6

1.6 PIC16F87X peripherals.................................................................................................................7

1.6.1 Attending peripheral by interruptions...................................................................................7

1.6.2 I/O ports.................................................................................................................................8

1.6.3 Timer T0.................................................................................................................................8

1.6.4 Timer T1.................................................................................................................................8

1.6.5 Timer T2.................................................................................................................................8

1.6.6 A/D converter.........................................................................................................................8

1.6.7 EEPROM memory..................................................................................................................8

1.6.8 UART.....................................................................................................................................8

1.6.9 I2C.........................................................................................................................................8

1.7 Desenvolupament de la pràctica/problema. Treball del grup (títol 2)...........................................9

1.7.1 El vostre primer subtítol (títol 3)...........................................................................................9

1.8 Bibliografia i referències consultades............................................................................................9

1.9 Pla de treball que heu preparat per resoldre el disseny................................................................10

1.10 “Fulls de dubtes” de l’EX2..........................................................................................................11

1.10.1 Sobre els apartats A), B) de l’arquitectura i instruccions del PIC......................................11

1.10.2 Sobre els apartats C) i D) de portals d’Internet..................................................................11

2

EX4: Analysing the PIC16F8XX microcomputer’s family

1.10.3 Full de dubtes sobre els perifèrics estudiats........................................................................12

MOLT IMPORTANT: Aquest curs s’espera de vosaltres que ja prepareu i editeu textos de certa qualitat, per tant: preneu aquest document de plantilla d’estils i formats. Amplieu-lo i modifiqueu-lo per plantejar, desenvolupar, solucionar i verificar el funcionament del vostre disseny. NO ES POT LLIURAR CAP TREBALL QUE NO SEGUEIX EXACTAMENT AQUESTA PLANTILLA:

- Fixeu-vos que l’índex de contingut de l’exercici es genera automàticament si respecteu els estils: Normal, Títol 1, Títol 2 i Títol 3.

- Respecteu i useu l’estil del peu de figura (Llegenda) i les referències creuades a les figures que s’actualitzen automàticament quan n’inseriu de noves.

- Respecteu i useu les referències creuades a la bibliografia numerada

- Passeu el corrector ortogràfic i repasseu la gramàtica tant si escriviu en anglès, castellà o català.

- Per eliminar errors, feu una segona lectura a través dels companys de grup abans de lliurar l’exercici

Consulteu-nos també qualsevol dubte que tingueu sobre l’edició de documents i aquesta plantilla en particular.

Tingueu en compte les anotacions i indicacions que us han fet els professors en els vostres treballs previs, per tal de no cometre les mateixes errades en aquest treball

ACTIVITATS

Qui Què Com Quan

Grup de treball cooperatiu Edició impresa (primera versió) de l’informe de l’exercici. Imprimiu la pàgina 1 i 2 amb l’índex actualitzat 1 i a partir de la pàgina 12

Amb la plantilla i seguint el documents de criteris de qualitat

Abans de la data límit que trobareu al pla de treball o bé al tauló d’anuncis de la web de SED

Els professors o els companys a través d’una correcció creuada

Correcció de la primera versió

Amb la plantilla d’avaluació

Com a màxim una setmana desprès del lliurament de la primera versió impresa

(amb caràcter voluntari)2

Grup de treball cooperatiu Edició electrònica (segona versió) del document complet amb la incorporació de les millores assenyalades

Amb un generador de fitxers PDF

Com a màxim una setmana desprès del lliurament de la correcció. S’enviarà per correu

1 Recordeu que l’índex de continguts el genera automàticament el processador de textos

2 És clar que la realització d’aquesta feina addicional millora la qualificació de l’exercici

3

EPSC – SED: Sistemes Electrònics Digitals

pels correctors electrònic als professors.

Professors Penjar a la web de SED el document per evidenciar el treball desenvolupat

A través d’un enllaç al document a l’apartat de Grups de Classe

Durant el quadrimestre, si s’escau

NOTA: També es valora la iniciativa. Si el grup cooperatiu vol realitzar una aplicació similar a la presentada en aquest exercici que incorpori els conceptes introduïts, bàsicament el disseny d’un altre sistema digital combinacional amb VHDL, que ho comuniqui als professors i es considerarà.

4

EX4: Analysing the PIC16F8XX microcomputer’s family

Analysing the PIC16F8XX microcomputer’s family

1.1 DescriptionThis exercise will place the basics for working with microcontrollers for the rest of the semester. Previous years’ exercises have produced slides and documentations related to common commercial chips, and this season our focus will be the study of PIC16F architecture and, specifically, its common peripherals.

1.2 Objectives After completing the task and studying practically all the Chapter 1 units, students will be able to:

- Identify commercial microcontrollers and their manufacturers

- Explain the basics of a microcontroller-based embedded system

- Analyse the architecture of an 8-bit microcontroller and describe their main blocks and peripherals

- Make clear the typical design flux for a microcontroller application: concept, hardware, program flux diagram, coding in assembler or C, Proteus simulation, prototype using evaluation board, verification, in-circuit debugging or microcontroller emulation, PCB design and production.

- Search books and the Internet to analyse information about microcontroller chips and their applications

- Document the work using a predefined word processor template and utilities: spelling and grammar, chapter enumeration, page headers and footers, hyperlinks, cross-references, figure captions, text styles, etc.

- Organize the study time and plan the cooperative group work time

1.3 Study time: The estimated student study time for this exercise is 1 weeks3: that means about 7 hours of cooperative work in laboratory sessions (TGA, TGB) or anywhere (TGC).

1.4 PIC16F87X central process unit (CPU) 1.4.1 Architecture

A) Study the PC16F877 datasheet to find answers for the following questions related to the basic building blocks which are represented in Fig. 1.

3 Students will work in cooperative groups for the whole semester. They will work an average time of 6.5 hours per week.

5

EPSC – SED: Sistemes Electrònics Digitals

http://epsc.upc.edu/projectes/sed/unitats/unitat_2_3/DataSheet_PIC16F87XA.pdf

1. Explain the differences between Harvard and Von Neumann microprocessor architectures

2. Explain what is the microcontroller flash program memory

3. Explain what is the stack memory and how it is used for

4. Explain the main characteristics of the Bank0 and 1 of the RAM memory

5. How many clock cycles are required for executing an assembler instruction?

6. Describe the fashion in which the following assembler instructions are executed and the resources involved

INCF PORTA,F (F = 1, PORTA = 05h)

DECFSZ PORTB,W (W = 0, PORTB = 06h)

7. Which is the main architectural difference between 8/16/32 bits microprocessors?

8. Which are the functions of the FLASH (ROM) memory and the RAM registers?

6

EX4: Analysing the PIC16F8XX microcomputer’s family

Fig. 1 PIC16F877 architecture

7

EPSC – SED: Sistemes Electrònics Digitals

1.4.2 PIC assembler: RISC instruction set

B) As an example to show the way you have understood PIC structure and its assembler language (see Fig. 2), explain how an 8-bit BCD addition will programmed.

Fig. 2 PIC16F877 instruction set

8

EX4: Analysing the PIC16F8XX microcomputer’s family

Remember that before attempting to code in assembler (or in C), a flux diagram must be sketched specifying program sequence, operations and routines. See the general proceeding to develop applications for embedded systems (with circuits including microcontrollers) in Fig. 3.

Fig. 3 Typical design flow for microcontroller or embedded systems

1.5 Visiting microcontroller portals C) Read information about other manufacturers’ microcontrollers4 and list Internet addresses for

accessing and gathering information for each 8-bit microcontroller.

D) Visit Internet portals in Fig. 4 and make a similar list devoted to electronic magazines, like EDN, which nowadays are the general source of information for being updated with reference to electronics engineering in general and microcontrollers in particular.

4 For instance: EX4 at http://epsc.upc.edu/projectes/sed/grups_classe/07-08_Q1/2AT4/07-08-Q1-2AT4.htm

9

EPSC – SED: Sistemes Electrònics Digitals

Fig. 4 Typical microcontroller portals for searching informaction

1.6 PIC16F87X peripherals In this section, some of the more common PIC16F peripherals will be studied. The procedure will be very similar for all of them: firstly, the hardware diagrams; secondly, the bits and registers that are in charge of the peripheral commanding; and finally, the explanation of a sample assembler program in charge of handling the peripheral. We will leave for the next EX5, a more serious proposal for an application exercise for the studied peripheral. Furthermore, the final project will combine into a single application the programming of several peripherals. Each cooperative group will study the specified peripheral.

Group PIC peripheral

G1 Timer T2

G2 UART

G3 Timer T1

G4 A/D

G5 Data EEPROM

10

EX4: Analysing the PIC16F8XX microcomputer’s family

1.6.1 Attending peripheral by interruptions

E) Explain schematic in Fig. 5.

Fig. 5 Interruption scheme for PIC16F87X microcontrollers

1.6.2 I/O ports

Hardware and control registers

Port A

Port B

Assembler example to initialize and use I/O ports:

Problem description: Incrementing a binary counter clicking a pushbutton (solving button bouncing effect) See PICDEM2 board first tutorial example at:

http://epsc.upc.edu/projectes/sed/unitats/unitat_2_5/picdem2.zip

Circuit schematic captured in Proteus-VSM

Flux diagram

Assembler code with comments to describe the main procedures

Proteus-VSM simulation

11

EPSC – SED: Sistemes Electrònics Digitals

I/O ports interruptions

The same problem but using interruptions instead polling the peripheral

1.6.3 Timer T0

Hardware and control registers

Assembler example to initialize and use Timer T0

An external event counter

A quartz crystal precision timer

T0 interruptions

The same examples but using interruptions

1.6.4 Timer T1

(The same layout that previous exercises)

1.6.5 Timer T2

1.6.6 A/D converter

1.6.7 EEPROM memory

1.6.8 UART

1.6.9 I2C

12

EX4: Analysing the PIC16F8XX microcomputer’s family

1.7 Desenvolupament de la pràctica/problema. Treball del grup (títol 2)1.7.1 El vostre primer subtítol (títol 3)

La instal·lació del Quartus-II (títol 4)

Afegiu aquí el vostre text (estil normal) encapçalat amb títols (Títol 2 i 3 i 4), amb figures (estil llegenda o “epígrafe”) i referències creuades en el text com aquesta Fig. 6 (és una referència creuada a la llegenda) a les figures que inseriu. Feu referència també en el text a les fonts bibliogràfiques o de web que consulteu d’aquesta manera [1] (és una referència creuada a l’element numerat [1]). Expliqueu perquè les heu consultat i quina informació útil heu trobat.

Fig. 6 Exemple de peu de figura que segueix la numeració de l’enunciat (llegenda)

1.8 Bibliografia i referències consultadesAmplieu i modifiqueu aquesta secció de referències.

[1] http://epsc.upc.edu/projectes/sed/ . Pàgina web de SED on trobareu materials i treballs de cursos anteriors. Vegeu la secció unitats didàctiques i grups de classe

[2] Brown,S., Vranesic, Z., “Fundamentals of digital logic with VHDL design”, Mc Graw-Hill, 2005

[3] http://epsc.upc.edu/projectes/ed/problemes/problemes_PA/Problemes_PA.htm . Pàgina web d’ED on hi ha el problema que descriu el funcionament i el disseny del descodificador HEX-7SEG.

[4] http://epsc.upc.edu/projectes/sed/projectes_aplicacio/Projectes_Aplic.htm . Lloc on hi trobareu el full de plantilla per a distribuir tasques entre els membres del grup cooperatiu

13

EPSC – SED: Sistemes Electrònics Digitals

1.9 Pla de treball que heu preparat per resoldre el disseny

Consulteu els documents de la web [4] per veure com us podeu preparar el pla de treball i el repartiment de tasques per realitzar una bona feina en equip. Useu diagrames de flux, mapes conceptuals, esquemes, taules, etc.

Aquest apartat és obligatori. Si no és present, no es corregeix l’exercici i s’ha de tornar a lliurar

14

EX4: Analysing the PIC16F8XX microcomputer’s family

1.10 “Fulls de dubtes” de l’EX25

1.10.1 Sobre els apartats A), B) de l’arquitectura i instruccions del PIC

Grup de treball:

Data:

Pla de treball:

Dubtes:

5 Afegiu, si és necessari, altres mitjos fulls com aquests per documentar el vostre progrés a través del projecte i poder realitzar consultes i discussions

Aquest apartat és obligatori. Si no és present, no es corregeix l’exercici i s’ha de tornar a lliurar

15

EPSC – SED: Sistemes Electrònics Digitals

1.10.2 Sobre els apartats C) i D) de portals d’Internet

Grup de treball:

Data:

Pla de treball:

Dubtes:

16

EX4: Analysing the PIC16F8XX microcomputer’s family

1.10.3 Full de dubtes sobre els perifèrics estudiats

Grup de treball:

Data:

Pla de treball:

Dubtes:

17