De presentatie wordt gedownload. Even geduld aub

De presentatie wordt gedownload. Even geduld aub

2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 1.

Verwante presentaties


Presentatie over: "2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 1."— Transcript van de presentatie:

1 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 1

2 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 2 Les 4 - onderwerpen DB036 schema: Luidsprekertje read-modify-write / shadow registers macro’s DB036 schema: LEDs en 7-segment displays opdrachten: –Beep –Tellen op een enkel 7-segment display –Multiplexen (tellen op meerdere displays) –verzin je eigen opdracht

3 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 3 DB036 circuit – luidspreker

4 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 4 DB036 circuit – luidspreker

5 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 5 PIC16F917 memory map

6 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 6 read-modify-write : IO pin

7 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 7 read-modify-write (fout) clrf PORTA bsf PORTA, 0 bsf PORTA, 1 bsf PORTA, 2 bsf PORTA, 3 bsf PORTA, 4 bsf PORTA, 5 bsf PORTA, 6 bsf PORTA, 7

8 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 8 read-modify-write (goed) clrf PORTA_SHADOW call PORTA_FLUSH bsf PORTA_SHADOW, 0 call PORTA_FLUSH bsf PORTA_SHADOW, 1 call PORTA_FLUSH bsf PORTA_SHADOW, 2 call PORTA_FLUSH... PORTA_FLUSH movfw PORTA_SHADOW movwf PORTA return

9 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 9 wat is een macro naam voor een aantal regels text, eventueel met parameters wordt letterlijk ingevoegd bank0 macro bcfSTATUS, RP0 bcfSTATUS, RP1 endm

10 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 10 macro voorbeeld en gebruik FLUSH_MACRO MACRO Shadow, Port CBLOCK Shadow ENDC MOVFW Shadow MOVWF Port RETURN ENDM PORTA_FLUSHFLUSH_MACRO PORTA_SHADOW, PORTA PORTB_FLUSHFLUSH_MACRO PORTB_SHADOW, PORTB PORTC_FLUSHFLUSH_MACRO PORTC_SHADOW, PORTC PORTD_FLUSHFLUSH_MACRO PORTD_SHADOW, PORTD PORTE_FLUSHFLUSH_MACRO PORTE_SHADOW, PORTE

11 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 11 Macro – listing (.lst)

12 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 12 Macro  Subroutine marco heeft geen call/return (gebruikt de stack niet) subroutine aanroep is altijd 1 statement macro ‘aanroep’ voegt de complete macro in een macro kan assembly-time argumenten hebben

13 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 13 DB036 circuit – 74HC259 adresseable latch G CLR D S0.. S2

14 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 14 DB036 circuit – 74HC259 adresseable latch GCLR

15 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 15 DB036 circuit – 74HC259 adresseable latch

16 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 16 DB036 circuit – displays and LEDs

17 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 17 LatchWrite (1) ;================================================================ ; ; segments.asm ; ;================================================================ ; initialisation etc for DB036 #include GOTO MAIN

18 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 18 LatchWrite (2) ;================================================================ ; ; Shadow Registers and Flush subroutines ; ;================================================================ FLUSH_MACRO MACRO Shadow, Port CBLOCK Shadow ENDC MOVFW Shadow MOVWF Port RETURN ENDM PORTA_FLUSHFLUSH_MACRO PORTA_SHADOW, PORTA PORTB_FLUSHFLUSH_MACRO PORTB_SHADOW, PORTB PORTC_FLUSHFLUSH_MACRO PORTC_SHADOW, PORTC PORTD_FLUSHFLUSH_MACRO PORTD_SHADOW, PORTD PORTE_FLUSHFLUSH_MACRO PORTE_SHADOW, PORTE

19 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 19 LatchWrite (3) ;================================================================ ; ; LatchWrite ; ; set outputs of the 74HC259 adresseable latch ; according to the value in W ; ;================================================================ CBLOCK LatchWritePattern ENDC LatchWrite ; save outputs to be activated MOVWF LatchWritePattern ; make gate line high (= inactive) BSF PORTB_SHADOW, 5 CALL PORTB_FLUSH ; make address and data 0 movlw 0xF0 andwf PORTD_SHADOW, f

20 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 20 LatchWrite (4) LatchWriteNext ; assume data line low, set to high only when ; the (next) bit of LatchWritePattern is 1 RRF LatchWritePattern, f SKPNC BSF PORTD_SHADOW, 3 ; output address and data CALL PORTD_FLUSH CALL LatchWriteReturn ; toggle gate line BCF PORTB_SHADOW, 5 CALL PORTB_FLUSH CALL LatchWriteReturn BSF PORTB_SHADOW, 5 CALL PORTB_FLUSH CALL LatchWriteReturn

21 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 21 LatchWrite (5) ; clear bit 3 and increment address BCF PORTD_SHADOW, 3 INCF PORTD_SHADOW, F ; if carry into bit 3 we are done BTFSS PORTD_SHADOW, 3 GOTO LatchWriteNext LatchWriteReturn RETURN

22 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 22 LatchWrite (6) MAIN MOVLW 0x02 CALL LatchWrite MOVLW 0xAA MOVWF PORTD SLEEP ;================================================================ ; end of assembler source ;================================================================ END

23 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 23 segment letters A B C DFDF E F G DP http://en.wikipedia.org/wiki/Seven-segment_display

24 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 24 segment letters PIC pinDisplay Segment RD0A RD1B RD2C RD3D RD4E RD5F RD6G RD7DP let op: active low !

25 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 25 multiplexen Laat Digit 1 zien (wacht) Doe eventueel ander werk Laat Digit 2 zien (wacht) Laat Digit 3 zien (wacht) Laat Digit 4 zien (wacht)

26 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 26 multiplexen Laat het volgende Digit zien Doe eentueel ander werk eventueel (extra) vertraging

27 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 27 opdrachten les 4 - 1: beep Maak een programma dat 1 keer een piep laat horen (bv 1/4 seconde op 1 kHz) Piepen is niets anders dan knipperen, maar dan met een luidspreker in plaats van een LED, en wat sneller. 1 kHz = 1ms per puls = 500 us hoog / 500 us laag 500 us = 1000 instructies bij 8 MHz 1/4 seconde = 250 pulsen

28 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 28 opdrachten les 4 - 2 : tellen tel op de 1 cijfer van het 7-segment display van 0 tot F (en dan weer opnieuw, bv 1 tikken per seconde) Gebruik een sprongtabel om te vertalen van een getal (0..F) naar het bitpatroon van de segmenten.

29 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 29 opdrachten les 4 - 3 : tellen + Kitt tel op de 3 cijfer van de 7-segment displays van 0 tot 999 (en dan weer opnieuw, bv 5 tikken per seconde), en laat tegelijk het Kitt patroon zien op de LEDs. Gebruik voor het tellen voor ieder digit een aparte RAM locatie.

30 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 30 opdrachten les 4 - 4 : verzin je vrije opdracht (voorzover je dat nog niet hebt gedaan) De laatste twee/drie lessen (en thuis!) ga je werken aan een vrije opdracht. Verzin zelf een project(je). Stem af. Schijf zelf de opdracht. citeria: niet te makkelijk niet te moeilijk hardware gebruiken is een plus, externe hardware plus plus

31 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 31 Mogelijke onderwerpen voor les 5/6 Schakelaartjes uitlezen (dender) Muziek A/D converter uitlezen (potmeter, M335, LDR) UART (serieel naar PC via de 2e USB connector) Werking IR afstandsbedieningen Interfacen van een PC keyboard en/of muis

32 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 32 een paar suggesties: Muziekjes (Fur Elise, Jingle Bells, etc) rekenmachine beat detector + patroon licht => geluid (random?) RC5 IR zender; RC5 ontvanger voorwerp-detector (IR zender + ontvanger) Reactiesnelheid tester spelletjes ‘Kitt’ display met 10 verschillende patronen (selecteer mbv de knoppen, sla op in de EEPROM) iets externs, bv een motor aansturen, PC keyboard, TV, iets loggen naar een PC en daar iets mee doen

33 2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 33 TL431 Voltage Reference chip


Download ppt "2PROJ5 – PIC assembler Hogeschool Utrecht / Institute for Computer, Communication and Media Technology 1."

Verwante presentaties


Ads door Google