1 / 21

Les 5 - onderwerpen

Les 5 - onderwerpen. DB038 hardware : 7-segment display multiplexen 16F887 / DB038 hardware : A/D conversie 16F887 : memory banks Opdracht1 : decimaal tellen op 4 displays Opdracht2 : A/D conversie

Télécharger la présentation

Les 5 - onderwerpen

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

E N D

Presentation Transcript


  1. Les 5 - onderwerpen • DB038 hardware : 7-segment display multiplexen • 16F887 / DB038 hardware : A/D conversie • 16F887 : memory banks • Opdracht1 : decimaal tellen op 4 displays • Opdracht2 : A/D conversie  Lees van de DB038 manual hoofdstuk 3 door (PIC 14-bit architecture and instruction set summary) Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

  2. multiplexen Laat Digit 1 zien (wacht) Laat Digit 2 zien (wacht) Laat Digit 3 zien (wacht) Laat Digit 4 zien (wacht) Doe eventueel ander werk 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? Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

  4. DB038 – multiplexers DB038 manual 2.8 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 Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

  6. PIC – A/D – configure pin as analog 16F887 datasheet p 99-108 Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

  7. PIC – A/D – aan zetten 16F887 datasheet p 99-108 Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

  8. PIC – A/D – channel  16F887 datasheet p 99-108 Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

  9. PIC – A/D – clock 16F887 datasheet p 99-108 Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

  10. PIC – A/D – start, wait 16F887 datasheet p 99-108 Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

  11. PIC – A/D – start, wait   16F887 datasheet p 99-108 Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

  12. PIC – A/D – result format 16F887 datasheet p 99-108 Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

  13. PIC – A/D – enable, go / done 16F887 datasheet p 99-108 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) Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

  15. 15 • Maak pin RA1 een ingang (bit 1 in TRISA) • Maak poort A een digitale poort: ANSEL = 0 CMCON0 = 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 PIC16F887 memory map Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

  16. PIC –register bank selection 16 Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

  17. banksel 0063 1683 1303 00099 banksel TRISA 0065 1485 00100 bsf ( TRISA & 0x7F ), 1 00101 0066 1683 1703 00102 banksel ANSEL 0068 0188 00103 clrf ( ANSEL & 0x7F ) 00104 0069 1283 1303 00105 banksel 0 17 banksel TRISA bsf ( TRISA & 0x7F ), 1 banksel ANSEL clrf ( ANSEL & 0x7F ) banksel 0  Gebruik dus altijd banksel, en schakel terug naar bank 0! DB038 manual 3.9 Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

  18. Code paging 11 bits == maar 2k instructies...

  19. Code paging Als je minder dan 2k code gebruikt  geen probleem Anders: GOTO  LGOTO CALL  LCALL Maar: LGOTO en LCALL worden vertaald naar meerdere instructies, dus je kan niet skippen! Wel kan: PAGESEL daarzo SKPNZ GOTO daarzo Let op pagesel – banksel ! DB038 manual 3.8

  20. Opdracht 1 : tel decimaal op 4 zeven-segment displays Declareer 4 bytes waarin je 4 decimale digits (getallen) opslaat. Maak een verhoog subroutine die de 4-dgit decimale waarde met 1 verhoogt. Let op de carry van een digit naar een hoger digit. Laat de nieuwe waarde zien op de zeven-segment displays. Weer verhogen, weer laten zien, etc. Zorg dat je maar 1 in de zoveel keer verhoogt. 20 Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

  21. oefening 2 : A/D, display Schrijf een programma dat de potentiometer uitleest en (hexadecimaal) weergeeft op de rechter twee 7-segment displays. Hogeschool Utrecht / Institute for Computer, Communication and Media Technology

More Related