PIC Interrupts PIC Microcontroller by Ravinder Nath Rajotiya - September 4, 2020May 31, 20210 PIC Interrupts Introduction: PIC16F877 has 14 interrupt sources. The following registers are used for setting the interrupt and checking the status of the interrupt. These are INTCON Register (04 registers, duplicated in each bank addresses 0Bh, 8Bh, 10Bh, 18Bh) PIE1 Register (Address 8Ch ) PIR1 Register (Address 0Ch) PIE2 Register (Address 8Dh) PIR2 Register( Address 0Dh) Figure-1 illustrates how the request from the interrupt source is communicated to the CPU. Table-1 shows the various sources of interrupts, and the registers used to enable the interrupts and the status flags Type Interrupt Register SFR Address REGISTER INTERRUPT ENABLE BIT INTERRUPT FLAG BIT STATUS FLAG REGISTER Status(Flag) Register SFR Address Global 0Bh / 8Bh/10Bh, 18Bh INTCON GIE Peripheral 0Bh / 8Bh/10Bh, 18Bh INTCON PEIE Timer0 0Bh / 8Bh/10Bh, 18Bh INTCON T0IE T0IF INTCON 0Bh / 8Bh External 0Bh / 8Bh/10Bh, 18Bh INTCON INTE INTF INTCON 0Bh / 8Bh PortB 0Bh / 8Bh/10Bh, 18Bh INTCON RBIE RBIF INTCON 0Bh /8Bh Parallel Slave Port Read/Write 8Ch PIE1 PSPIE PSPIF PIR1 0Ch ADC 8Ch PIE1 ADIE ADIF PIR1 0Ch USART
PIC Memory Organization PIC Microcontroller by Ravinder Nath Rajotiya - September 2, 2020September 4, 20200 Memory Organization: The internal block diagram iPIC16F87x in figure1 shows the three memory block the program memory, EEPROM data memory and the RAM; some controller like 16C61 has only two blocks of memory program memory and data memory. As shown the program memory and the data memory use separate buses for concurrent access of these memory. 16F877 has 8K x 14 bit word memory and 8 byte stack organization. Figure-1 shows the program and the stack memory map organization. Whereas the program memory is used to store the application program, the stack memory is used only for storing return addresses and some critical data that is required to be saved while transferring the contol of the program such as call to subroutine
PIC Instruction Set PIC Microcontroller by Ravinder Nath Rajotiya - September 2, 2020September 4, 20200 PIC Instruction Set: PIC is RISC based architecture supporting only 35 instructions. These instructions can be classified in the following categories: 1. Register File Operations: Byte oriented operations Bit oriented operations Literal and control operations 2. Based on Functions Data Transfer Operations Arithmetic Operations Logical Operations Shift and Rotate Branch and Return These instructions are shown in the Byte-Oriented Operations Mnemonic Description Cycles 14-bit OPCode Status Affected ADDWF f,d Add W and F 1 0 0111 dfff ffff C, DC, Z ANDWF f,d Logical AND W with f 1 000101 dfff ffff Z CLRF f Clear f 1 0000011fff ffff Z CLRW Clear W 1 00 0001 0xxx xxxx Z COMF f,d Complement f 1 00 1001 dfff ffff Z DECF f,d Decrement f 1 00 0011 dfff ffff Z DECFSZ f,d Decrement f and skip if zero 1(2) 00 1011 dfff ffff INCF f,d increment 1 00 1010 dfff ffff Z INCFSZ f,d Increment f, and skip if zero 1(2) 00 1111 dfff ffff IORWF f,d Inclusive OR W with f 1 00 0100 dfff ffff Z MOVF f,d Move f 1 00 1000 dfff ffff Z MOVWF f Move W to
Internal Architecture of PIC microcontroller PIC Microcontroller by Ravinder Nath Rajotiya - September 2, 2020September 2, 20200 Internal Architecture of PIC microcontroller: The internal architecture of 8086 shows the interconnection of all important components of the controller along with its data path. Figure-1 shows the internal architecture of 16F877 microcontroller PIC16F877 architecture shows the following components: Figure-1: Internal Architecture of PIC16F877 I/O PORTS : It has five I/O ports PORT A,B,C,D,E. Port A is 6-bit wide, and is used also as analog input. Port E is 3-bit wide i/o port, and also used as analog inputs and Read,write and chip select signals Communication Protocols : USART, I2C, PSP, Synchronous Serial, Timers : T0, T1, T2. Timer T0 and T2 are 8-bit and T1 is 16-bit timer counter. It is used to generate precise count, and delay signals and used to
PIC introduction PIC Microcontroller by Ravinder Nath Rajotiya - September 2, 2020September 2, 20200 Introduction PIC series of controller high performance, low cost RISC controllers. It is based on Harvard architecture allowing use of separate instruction and data buses. The architecture allows a typical 14 bit wide instructions word length and 8-bit data width. Being RISC controller, it supports only 35 instructions and all instructions except jump and branch instructions execute in single cycles. It has large number of registers arranged in banks of register. The number of register banks depends on the PIC family and the type of controller. A quick comparison is given below: Controller No. of PINS Clock speed No. of instructions Program Memory EEPROM RAM Others 16C61 18 (13 I/O pins) 20 MHz 35 1Kx 14-bits x 36 Bytes PoR, PWRT, WDT with onChip Osc, SLEEP mode, 3 Timers, CCP, Synchronous Serial Port (SSP) with SPI