11
PIC18 Peripherals

PIC18 Peripherals. PIC18F452/458 Peripherals – Data ports – – A 6-bit – B 8-bit – C8-bit – D8-bit – E3-bit Timer/counter modules – 0 [8-bit], 1 [16-bit],

Embed Size (px)

Citation preview

Page 1: PIC18 Peripherals. PIC18F452/458 Peripherals – Data ports – – A 6-bit – B 8-bit – C8-bit – D8-bit – E3-bit Timer/counter modules – 0 [8-bit], 1 [16-bit],

PIC18 Peripherals

Page 2: PIC18 Peripherals. PIC18F452/458 Peripherals – Data ports – – A 6-bit – B 8-bit – C8-bit – D8-bit – E3-bit Timer/counter modules – 0 [8-bit], 1 [16-bit],

PIC18F452/458 Peripherals –

• Data ports – – A 6-bit– B 8-bit– C 8-bit– D 8-bit– E 3-bit

• Timer/counter modules – 0 [8-bit], 1 [16-bit], 2 [8-bit], 3 [16-bit]

Page 3: PIC18 Peripherals. PIC18F452/458 Peripherals – Data ports – – A 6-bit – B 8-bit – C8-bit – D8-bit – E3-bit Timer/counter modules – 0 [8-bit], 1 [16-bit],

• CCP/PWM modules [2]• I2C/SPI serial port • USART [RS-232, RS-485]• ADC [10-bit] with 10 way input multiplexer• EEPROM [256 byte]

Page 4: PIC18 Peripherals. PIC18F452/458 Peripherals – Data ports – – A 6-bit – B 8-bit – C8-bit – D8-bit – E3-bit Timer/counter modules – 0 [8-bit], 1 [16-bit],

PIC instruction set

• PIC instruction set has a small no. of simple (RISC) instructions:– PIC16 series – 35 inst. coded into 14 bits– PIC18 series – 59 16…– PIC24 series – 71 24…

Most instructions are executed in one instruction cycle that corresponds to 4 clock cycles.

Hence, a PIC operating at 40 MHz clock frequency will have an instruction rate of 10 MIPS.

Page 5: PIC18 Peripherals. PIC18F452/458 Peripherals – Data ports – – A 6-bit – B 8-bit – C8-bit – D8-bit – E3-bit Timer/counter modules – 0 [8-bit], 1 [16-bit],

Byte-oriented file register operations

• Byte-oriented file register operations – ADDWF Add W and f result in W or fCLRF clear fDECF decrement fMOVF Move contents of f to f or W

Page 6: PIC18 Peripherals. PIC18F452/458 Peripherals – Data ports – – A 6-bit – B 8-bit – C8-bit – D8-bit – E3-bit Timer/counter modules – 0 [8-bit], 1 [16-bit],

Bit-oriented file register operations

BCF clear bit in f

BTFSC test bit in f; skip if clear

Page 7: PIC18 Peripherals. PIC18F452/458 Peripherals – Data ports – – A 6-bit – B 8-bit – C8-bit – D8-bit – E3-bit Timer/counter modules – 0 [8-bit], 1 [16-bit],

Control instructions

CALL call subroutine (funtion)RETURN return from subroutine (function)

BRA branch unconditionallyBNZ branch if not zero

Page 8: PIC18 Peripherals. PIC18F452/458 Peripherals – Data ports – – A 6-bit – B 8-bit – C8-bit – D8-bit – E3-bit Timer/counter modules – 0 [8-bit], 1 [16-bit],

Literal instr.

MOVLW move literal to WADDLW add literal to W

Page 9: PIC18 Peripherals. PIC18F452/458 Peripherals – Data ports – – A 6-bit – B 8-bit – C8-bit – D8-bit – E3-bit Timer/counter modules – 0 [8-bit], 1 [16-bit],

Status register

• 8-bit status register – – N negative bit – result of arithmetic operation was negative – OV overflow bit – overflow occurred for signed arithmetic

– Z zero bit – DC digit carry bit – carry out from 4th low order bit of result

– C carry bit – carry out from MSB of result

The bits of the status reg can be used for conditional branches, e.g.,

- BNZ branch if not zero- BOV branch if overflow

Page 10: PIC18 Peripherals. PIC18F452/458 Peripherals – Data ports – – A 6-bit – B 8-bit – C8-bit – D8-bit – E3-bit Timer/counter modules – 0 [8-bit], 1 [16-bit],

CCS PIC compiler

• Compiler – high-level language prog to machine instructions for the target processor

• Cross-compiler – is a compiler that runs on a processor that is different from the target processor

• E.g., CCS cross-compiler• Most embedded systems are now

programmed using C/C++ lang.

Page 11: PIC18 Peripherals. PIC18F452/458 Peripherals – Data ports – – A 6-bit – B 8-bit – C8-bit – D8-bit – E3-bit Timer/counter modules – 0 [8-bit], 1 [16-bit],

PC with CCS compiler USB

ICD2 debugger PIC system

• Programs are edited and compiled to PIC machine instructions on a PC

• PIC machine instructions are uploaded from PC to PIC system via the ICD2 debugger [e.g., microchip MPLAB ICD2]

• Code is executed on the PIC system and can be debugged (break points, inspect variables, single step, etc.) using PC