Beruflich Dokumente
Kultur Dokumente
Chapter #3
PIC18F4585 Architecture
4 16 bits-timers (T0 T3). 5 I/O ports (A, B, C, D, y E) . Serial port, parallel communication, and A/D converter of 10 bits and 11 channels.
Source: PIC18C Reference Manual, Microchip DS39500a, 2000 Dr. Rodolfo J. Castell Z. 4
Description External Clock External Clock with I/O pin enabled Low Frequency (Power) Crystal Crystal/Resonator High Speed Crystal/Resonator External Resistor/Capacitor External Resistor/Capacitor with I/O pin enabled High Speed Crystal/Resonator with 4x fequency PLL multiplier enabled
Source: PIC18C Reference Manual, Microchip DS39500a, 2000 Dr. Rodolfo J. Castell Z. 5
Bit
0
Symbol
SCS
Reset value
0
Description
System Clock Switch bit: 1 = Timer1 Oscillator is the system clock 0 = Use External clock Unimplemented bits. Read as 0
17
FOSC2:FOSC0 Configuration Bits 111 110 101 100 011 010 001 000
Source: PIC18C Reference Manual, Microchip DS39500a, 2000 Dr. Rodolfo J. Castell Z. 7
Source: PIC18F4585 Data Sheet, Microchip DS39625C, 2007 Dr. Rodolfo J. Castell Z. 8
Description External Clock External Clock with I/O pin enabled Low Frequency (Power) Crystal Crystal/Resonator High Speed Crystal/Resonator External Resistor/Capacitor with FOSC/4 output on RA6 External Resistor/Capacitor with I/O on RA6 High Speed Crystal/Resonator with PLL multiplier enabled Internal Oscillator with FOSC/4 output on RA6 and I/O on RA7 Internal Oscillator with I/O on RA6 and RA7
9
Source: PIC18F4585 Data Sheet, Microchip DS39625C, 2007 Dr. Rodolfo J. Castell Z.
Bit
0-1
Symbol
SCS1:SCS0
Reset value
00
Description
System Clock Select bits: 1x = Internal Oscillator Block 01 = Timer1 Oscillator 00 = Primary Oscillator specified by FOSC3:FOSC0 of CONFIG1H
INTOSC Frequency Stable bit 1 = Stable. 0 = Not stable Oscillator Start-up time-out status bit Internal Oscillator Frequency Select Bits 111 = 8MHz 011 = 500KHz 110 = 4MHz 010 = 250KHz 101 = 2MHz 001 =125KHz 100 = 1MHz 000 = 31KHz
Idle Enable Bit
2 3 6-4
0 0 100
IDLEN
Source: PIC18F4585 Data Sheet, Microchip DS39625C, 2007 Dr. Rodolfo J. Castell Z.
10
FOSC3:FOSC0 Configuration Bits 11xx 1001 1000 0111 0110 0101 0100
Dr. Rodolfo J. Castell Z.
Oscillator Mode XT LP
2M Program Space
Programs Address Bus Datas Address Bus
4K (212= 4096)
21 lines 16 lines
12 lines
Processor
8 lines
Instructions Bus
Data Bus
16 bits Opcode
12
12 Address PC 21 Program Memory (Flash) 16 12 IR 8 Instruction Decoder 8 8 FSRs 4 4 Address 12 Data Memory (SRAM) MPX
31 Levels Stack
Internal Resources
Clock
ALU
8 STATUS
W (accumulator)
13
14
15
16
48 KB @ el PIC18F4585
BFFFH C000H
Stack
2 MB
1FFFFFH 7 Dr. Rodolfo J. Castell Z. 0 17
Address Bus
PCLATU
PCLATH
<20 0>
20 16 15 8 7 0
31 Level Stack
18
19
20
10
Contents
Instruction
Operand(s)
MOVLW MOVFF
21
22
11
SFRs
F80H FFFH 23
24
12
25
The only instruction from PIC18 core instruction set that fully specifies by itself the 12-bit address of both, the source and target registers, is MOVFF.
26
13
27
28
14
29
I/O Ports. Interruptions. Serial Port. Timers. A/D Converters. CPU Functionality.
30
15
PLUSW0 PREINC0 POSTDEC0 POSTINC0 INDF0 INTCON3 INTCON2 INTCON PRODL PRODH TABLAT TBLPTRL TBLPTRH TBLPTRU PCL PCLATH PCLATU TOSL TOSH TOSU
31
32
16
Data
8 Bits Carry Bit
WREG ALU
8 Bits N, OV, Z, DC, C Dr. Rodolfo J. Castell Z. 33
STATUS
Bit
0
Symbol
C
Reset value
R/W-x
Description
Carry/borrow bit (ADDWF, ADDLW, SUBLW, SUBWF) 1 = A carry-out from the MSb of the result occurred 0 = No carry Digit carry/borrow bit (ADDWF, ADDLW, SUBLW, SUBWF) 1 = A carry-out of the Least Significant Nibbles Msb of the result occurred 0 = No carry-out from the 4th low order bit of the result Zero Bit 1 = The result of an arithmetic or logic operation is cero. 0 = The result of an arithmetic or logic operation is NO cero. Overflow Bit 1 = Overflow on bit 7 for arithmetic signed operations. 0 = No overflow. Negative Bit 1 = Result was negative, when the MSb = 1 0 = Result was positive. Unimplemented, read as0
Significado de los valores de Reset R Readable bit 1 - Bit is set 0 Bit is cleared x Bit is unknown U Unimplemented bit, read as 0
DC
R/W-x
R/W-x
OV
R/W-x
R/W-x
5-7
U-O
W Writable bit
34
17
35
36
18
37
I/O Ports
38
19
I/O Ports
39
Description A/D input channel 0 / Comparator Voltage ref A/D input channel 1 A/D input channel 2 / Negative Voltage ref. A/D input channel 3 / Positive Voltage reg. TIMER 0 External Clock Signal Input A/D input channel 4 External Oscillator External Oscillator
Default Function (POR) As Analog Inputs (AN0) As Analog Inputs (AN1) As Analog Inputs (AN2) As Analog Inputs (AN3) As Digital Input (RA4) As Analog Inputs (AN4) As Digital Input (RA6) External RC Oscillator 40
20
41
Port A
42
21
Description A/D channel 10 / External Interruption #0 A/D channel 8 / External Interruption #1 CAN transmit / External Interruption #2. CAN receive A/D channel 9 / Interrupt on pin change Interrupt on pin change Interrupt on pin change Interrupt on pin change
Default Function (POR) As Analog Inputs (AN10) As Analog Inputs (AN8) As Analog Inputs As Analog Inputs As Analog Inputs (AN9) As Digital Input As Digital Input As Digital Input 44
22
45
Port B
list p=18f4585 #include "p18f4585.inc" CONFIG CONFIG MOVLW MOVWF CLRF CLRF MOVLW MOVWF PBADEN = OFF LVP= OFF 0x0F ADCON1 PORTB LATB 0xFF / 0x00 TRISB ; CONFIG3H.1 = 0: RBO RB4 digital ; CONFIG4L.2 = 0: RB5 digital ; WREG = 0x07 ; Disables A/D Converter ; PORTB reset ; Clears latch ; Set bits as inputs or outputs
46
23
Their double functionality is activated when the related devices are used. (see data sheet)
47
Port C
48
24
Description Parallel Slave Port / Comparator 1 Pos IN Parallel Slave Port / Comparator 1 Neg IN Parallel Slave Port / Comparator 2 Pos IN Parallel Slave Port / Comparator 2 Neg IN Parallel Slave Port / Comparator Out Parallel Slave Port / Comparator Out Parallel Slave Port / Comparator Out Parallel Slave Port / Comparator Out
Default Funtion (POR) Comparator 1 Pos IN (C1IN+) Comparator 1 Neg IN (C1IN-) Comparator 2 Pos IN (C2IN) Comparator 2 Neg IN (C2IN-) I/O Digital I/O Digital I/O Digital I/O Digital 49
Port D
50
25
Port D
; WREG = 0x07 ; Disables Comparators CM2:CM0 = 111 ; PORTD reset ; Clears latch ; Set bits as inputs or outputs
51
Description A/D channel 5 A/D channel 6 A/D channel 7 External Reset Input
Default Function (POR) As Analog Inputs (AN5) As Analog Inputs (AN6) As Analog Inputs (AN7) Master Reset
52
26
53
loop
54
27
Instruction
Fetch D R P W MOVF PORTC, W ;WREG Port C
Fetch
D R P
MOVWF PORTB
;Port B WREG
55
loop
56
loop
Dr. Rodolfo J. Castell Z.
TRISB ;PORTB as Output TRISC ;PORTC as Input PORTC, PORTB ;PORTB PORTC loop
28
Some of the features that can be configured are: Oscillator selection, Type of Resets, Interruptions, Code Protection. Etc see data sheet.
Dr. Rodolfo J. Castell Z. 57
58
29
Configuration Registers
FLASH ROM`
CONFIG1H CONFIG2L CONFIG2H CONFIG3H CONFIG4L CONFIG5L CONFIG5H CONFIG6L CONFIG6H CONFIG7L
59
The way to set the configuration through table writing will be seen in the following chapter when table operations are introduced.
60
30
61
Configuration Registers
62
31
7. Minimum System
10K 100K
27 pF
Vcc
4 MHz
27 pF
Dr. Rodolfo J. Castell Z. 63
32