This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
2PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
Lees van de DB038 manual hoofdstuk 3 door (PIC 14-bit architecture and instruction set summary)
2PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
2
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)
2PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
3
Ghosting bij multiplexen
Laat een digit zien:• (RA2 is hoog)• Zet het nieuwe adres op RE0..RE2• Zet het nieuwe segment-patroon op RD0..RD7• Wacht 1 ms
- Wat gaat hier (heel even) fout?- Hoe is dit op te lossen?
2PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
4
DB038 – multiplexers
DB038 manual 2.8
2PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
5
PIC – A/D
A/D converter vertaald een analoge spanning naar een waarde 0..255 (8 bits) of 0..1023 (10 bits)
RA0
16F887 datasheet p 99-108
2PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
6
PIC – A/D – configure pin as analog
16F887 datasheet p 99-108
2PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
7
PIC – A/D – aan zetten
16F887 datasheet p 99-108
2PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
8
PIC – A/D – channel
16F887 datasheet p 99-108
2PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
9
PIC – A/D – clock
16F887 datasheet p 99-108
2PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
10
PIC – A/D – start, wait
16F887 datasheet p 99-108
2PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
11
PIC – A/D – start, wait
16F887 datasheet p 99-108
2PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
12
PIC – A/D – result format
16F887 datasheet p 99-108
2PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
13
PIC – A/D – enable, go / done
16F887 datasheet p 99-108
2PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
14
Read an analog input• Zet de juiste code op poort RE• Configureer de pin (RA0) als input (TRISA)• Configureer de pin (RA0 = AN0) in ANSEL als analoog• Activeer de A/D, selecteer het betreffende kanaal, selecteer
de conversie clock (ADCON0)• Selecteer VSS en VDD als referenties, en de alignment
(ADCON1)• wacht 100 us• start de conversie (ADCON0)• wacht tot de conversie voltooid is (ADCON0)• lees het resultaat (ADRESH, eventueel ADRESL)
2PROJ5 – PIC assembler
• Maak pin RA1 een ingang (bit 1 in TRISA)• Maak poort A een digitale poort:
ANSEL = 0CMCON0 = 0x07
• Zet een waarde 0x01, 0x02, 0x04 of 0x08 op PORTD• Zet een waarde 4 .. 7 op PORTE• Wacht ten minste 10 µs• Lees pin RA1 (hoog == toets is ingedrukt)• Doe dit voor alle 16 toetsen
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
15
PIC16F887 memory map
2PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology
16
PIC –register bank selection
2PROJ5 – PIC assembler
Hogeschool Utrecht / Institute for Computer, Communication and Media Technology