PIC microcontrollers
-
Upload
dennis-wells -
Category
Documents
-
view
43 -
download
1
description
Transcript of PIC microcontrollers
PIC Microcontrollers• Families
• Eigenschappen
• De PIC16C84• Eigenschappen
• Pinnen
• Interne structuur
• Instructieset
• De PIC16F877• Eigenschappen
• Interne structuur
De PIC controller• Families
– PIC 16C5x reeks
– PIC 16Cxxx reeks
– PIC 17Cxxx reeks
– PIC 18Cxxx reeks
• Met welke hebben wij te maken ?– PIC 16C84
– PIC 16F877
– 12 bit program word
– 14 bit program word
– 16 bit program word
– 16 bit program word
PIC Microcontrollers• Families
• Eigenschappen
• De PIC16C84• Eigenschappen
• Pinnen
• Interne structuur
• Instructieset
• De PIC16F877• Eigenschappen
• Interne structuur
Eigenschappen• Harvard Architectuur
– Program en Data Memory gebruiken verschillende bus
• Long Word instructions• Single Word instructions• Single Cycle instructions• Instruction Pipelining• Reduced Instruction Set• Register File Architecture:
– bv. 16C84 heeft 36 8-bits registers
• Orthogonal (symmetric) instructions– Alle instructies kunnen op elk register gebruikt worden
PIC Microcontrollers• Families
• Eigenschappen
• De PIC16C84• Eigenschappen
• Pinnen
• Interne structuur
• Instructieset
• De PIC16F877• Eigenschappen
• Interne structuur
De PIC 16C84 - eigenschappen• Eigenschappen
– 35 instructies– 1K-woord EEPROM– 36 8-bit interne registers– 64 bytes 8-bit RAM– Hardware stack met 8 levels voor jumps– 4 interrupt levels
– External INT op pin RB0– TMR0 overflow– Port B (pins 7:4) change– EEPROM write
– 15 special functions hardware registers– Directe, indirecte en relatieve adressering
De PIC 16C84 - pinning• Pinning
• – 13 I/O pinnen
– 20 mA current sink LEDs direct aan te sturen
– External interrupt op RB0
– Timer en oscillator pinnen
De PIC 16C84 - memory• 2 memory blockken
– Program memory
– Data memory
• Program memory– 13 bit 8K woorden
– Slechts 1K ingevuld
– Reset vector op 0000h
– Interrupt vector op 0004h
De PIC 16C84 - memory
• Data memory verdeeld in– Special functions register (SFR)
– General purpose SRAM
– EEPROM memory
• Banked SFR– Keuze via het status register
De PIC 16C84 – program counter• Addressering in het program memory
• Program counter (13 bits) = PCH (5bit) + PCL (8bit)• PCL is read/write • PCL heeft memory boundary van 256 bytes• PCH comes from PCLATH register• Vb. 16C84 heeft 1K CALL en GOTO hebben 11 bit address• Controleer of PAGE BITS juist staan !
PIC 16C84 – PORT A• Twee poorten : PORTA en PORTB
• Selectie van Input of Output door TRIS register– TRISA en TRISB
– TRISA bit = 1 INPUT
– TRISA bit = 0 OUTPUT
• Soorten pinnen– RA3:RA0 push-pull
– RA4 open collector
PIC 16C84 – PORT B• Selectie van Input of Output door TRISB register
– TRISA en TRISB
– TRISB bit = 1 High Z
– TRISB bit = 0 OUTPUT
• Soorten pinnen– RB7:RB4 geven interrupt
PIC 16C84 – Timer• Instelling gestuurd door OPTION register• Functies:
• 8 bit read/write
• 8 bit prescaler
• Select : internal or external clock
• Interrupt on overflow
PIC 16C84 – Speciale functies• EEPROM programmeerbaar in normale werking• In-circuit serial programming• Watchdog timer• Power-up timer• Code protection• SLEEP mode voor low-current operation• Clock met crystal of goedkoop RC circuit
PIC 16C84 – programmatie• Definities
– f : register file address, gaat van 0x00 tot 0x7f
– b : bit address within an 8-bit file register
– W: Working register (Accumulator)
– d : destination• Als d=0 : result in W
• Als d=1 : result in file register (default)
– k : constant or label
PIC 16C84 – instruction set• Literal and Control
• Voorbeeld: wis geheugen van 0x20 tot 0x2Fmovlw 0x20 ; initialize W register B0010 0000movwf FSR ; put in FSR register
LOOP clrf INDF ; clear indirect with FSRincf FSR ; increment FSR registerbtfss FSR,7 ; bit 7 test, skip if setgoto LOOP ; if NO, goto LOOP
CONTINUE: ; if YES, continue:
PIC 16C84 – Vb. gebruik• Verwissel inhoud van w met de inhoud van reg
• Kortere methode
movwf temp1 ;save wmovf reg,W ;save regmovwf temp2movf temp1,W ;old (w) -> regmovwf regmovf temp2,W ;old (reg) -> w
; w = 1010 1010 AA; reg = 0101 0101 55
xorwf reg,F ;w = AA, reg = FFxorwf reg,W ;w = 55, reg = FFxorwf reg,F ;w = 55, reg = AA
PIC Microcontrollers• Families
• Eigenschappen
• De PIC16C84• Eigenschappen
• Pinnen
• Interne structuur
• Instructieset
• De PIC16F877• Eigenschappen
• Interne structuur
De PIC 16F877• Complexer• 40 pins IC• 8 K Woord (14 bit)
Program memory• 368 Bytes data memory• 256 Bytes EEPROM• Ook hier slechts 35
instructies.• Speciale functies:
– 10 kanaals 8-bit analog input– SPI seriële poort– USART seriële
communicatie– Brown-out detection– In-circuit programmable
PIC 16F877 – I/O poorten• 3 Input/Output poorten
– PORT A : • push-pull op RA3:RA0 en RA5
• Open collector op RA4
PIC 16F877 – I/O poorten• PORT C :
• TRIS C=1 : INPUT
• TRIS C=0 : OUTPUT
• Meerdere functies. O.a. Schmitt trigger