Mid-Range Family Peripheral Configuration with C Programming

Size: px
Start display at page:

Download "Mid-Range Family Peripheral Configuration with C Programming"

Transcription

1 Mid-Range Family Peripheral Configuration with C Programming MCU 2 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28

2 Objectives At the end of this class you will: Understand the basic PICmicro peripherals and their associated registers Have HANDS ON experience initializing Mid-Range peripherals using the XC8 C compiler Understand interrupts and polling Write your own application code from scratch Slide 2

3 To get the most from this Class Ideally you should be familiar with the following: Writing simple programs in C Basic Mid-Range family Instruction set Data and Program memory organization MPLAB Integrated Development Environment Microchip ICD 2 debugger Slide 3

4 Agenda Brief review of Mid-Range Architecture, Instruction Set and Tools Using XC8 s C compiler with MPLAB Lab-Using PICC with MPLAB X IDE Interrupts on the Mid-Range PICmicro Lab-External Interrupt Lab Peripheral discussion: Input/Output Ports Timers Timer Timer Lab2-Timer Lab Timer2 Lab3-Timer2 Lab Slide 4

5 Agenda (cont.) Capture / Compare / PWM Module (CCP) Lab4-PWM & Lab5-Output Compare Labs Analog Comparator Analog to Digital Converters (ADC) Lab6-ADC Lab Addressable Universal Asynchronous & Synchronous Receiver & Transmitter (AUSART) I 2 C with the Master Synchronous Serial Port Wrap-Up and additional questions Slide 5

6 Mid-Range Family Basic Architecture and Development Tools 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28 6

7 Microchip s MCU Families /E Slide 7

8 Mid-Range PIC Block Diagram PROGRAM MEMORY Non-Volatile (Flash) Holds program instructions that tell CPU what to do Oscillator PIC6 Core Working STATUS OPTION ALU CPU The Brains Performs all instruction, logic, and mathematical processing DATA MEMORY Volatile (SRAM) Holds data under the control of instructions Slide 8

9 Mid-Range PIC Block Diagram PROGRAM MEMORY Oscillator PIC6 Core Working STATUS OPTION DATA MEMORY I/O PORTS BIT ADC ALU CPU Peripherals Hang Off the Data Bus COMPARATORS TIMERS EEPROM Cap/ Com/ PWM SPI / I 2 C VOLTAGE REF USART Slide 9

10 Flash Program Memory PROGRAM MEMORY Page Page Page 2 Page 3 Stores the instructions (your code) Tells the CPU what to do The amount of Program Memory is device specific All Instructions are 4-bits wide instruction = Program Memory Address Divided into pages Slide

11 Flash Program Memory Why do we need Program Memory paging? PROGRAM MEMORY h 7FFh 8h Page With a 4 bit instruction, only bits can be used to specify a program memory address in a single cycle FFFh h 7FFh 8h Page Page Opcode GOTO Instruction in Program Memory 2 = 248 addresses FFFh Page 3 Slide

12 SRAM Data Memory Divided into BANKs # of banks is device dependent (4 banks max) 2 groups of Registers: Special Function Registers (SFR) Control CPU and Peripheral functions General Purpose Registers (GPR) Store user defined variables Data Memory SFR GPR Bank Slide 2

13 Data Memory Banks h Special Function Registers 8h Special Function Registers h Special Function Registers 8h Special Function Registers Note Data Memory Addresses General Purpose Registers General Purpose Registers General Purpose Registers General Purpose Registers 28 Bytes 7Fh FFh Accesses 7h 7Fh 7Fh Accesses 7h 7Fh FFh Accesses 7h 7Fh Bank Bank Bank 2 Bank 3 Slide 3

14 Data Memory Banks Why do we need Data Memory banks? h DATA MEMORY SFR With a 4 bit instruction, only 7 bits can be used to specify a data memory address in a single cycle The STATUS register holds additional bits (RP, RP, IRP) used to select of 4 data banks. GPR Byte Oriented Instruction (i.e. ADDWF) Opcode 2 7 = 28 addresses 7Fh Bank Slide 4

15 A B C D INDF TMR PCL STATUS FSR PORTA PORTB PORTC PORTD PORTE PCLATH INTCON Data Memory SFRs Special Function Registers Bank Bank Bank 2 Bank A 8B INDF OPTION_REG PCL STATUS FSR TRISA TRISB TRISC TRISD TRISE PCLATH INTCON A B INDF TMR PCL STATUS FSR PORTB PCLATH INTCON INDF OPTION_REG PCL STATUS FSR TRISB PCLATH INTCON PIR 8C PIE C EEDATA 8C EECON PIR2 8D PIE2 D EEADR 8D EECON A 8B See data sheet for actual SFR locations Slide 5

16 Status Register bit 7 bit IRP RP RP TO PD Z DC C Reset Status Bits RP PD TO Power Down (SLEEP instr executed?) Time Out (WDT Timeout?) RP C DC Z ALU Status Bits Carry (Byte Overflow?) Digit Carry (Nibble (4 bit) Overflow?) Zero (Is the ALU Result s?) Slide 6

17 Status Register bit 7 bit IRP RP RP TO PD Z DC C Data Memory bank select bit (Indirect Addressing) Data Memory bank select bits (Direct Addressing) IRP RP RP RP BANKS & RP RP BANK BANKS & 2 BANK BANK2 BANK3 Slide 7

18 PIC6 Instruction Set 35 single word instructions All are single cycle except for program branches Byte Oriented Operations addwf f,d Add W and f andwf f,d AND W with f clrf f Clear f clrw - Clear W comf f,d Complement f decf f,d Decrement f decfsz f,d Decrement f, Skip if incf f,d Increment f incfsz f,d Increment f, Skip if iorwf f,d Inclusive OR W with f movf f,d Move f movwf f Move W to f nop - No Operation rlf f,d Rotate Left f through Carry rrf f,d Rotate Right f through Carry subwf f,d Subtract W from f swapf f,d Swap nibbles in f xorwf f,d Exclusive OR W with f Bit Oriented Operations bcf f,b Bit Clear f bsf f,b Bit Set f btfsc f,b Bit Test f, Skip if Clear btfss f,b Bit Test f, Skip if Set Literal and Control Operations addlw k Add literal and W andlw k AND literal with W call k Call subroutine clrwdt - Clear Watchdog Timer goto k Go to address iorlw k Inclusive OR literal with W movlw k Move literal to W retfie - Return from interrupt retlw k Return with literal in W return - Return from Subroutine sleep - Go into standby mode sublw k Subtract W from literal xorlw k Exclusive OR literal with W Slide 8

19 PICmicro Development Tools 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28 9

20 MPLAB X Integrated Development Environment Slide 2

21 MPLAB X IDE Unified Development Platform Single, unified, graphical user interface Supports all Microchip 8, 6 and 32-bit MCUs Supports Microchip C & C++ compilers, simulators, emulators, debuggers and starter kits FREE Supports many third-party compilers, RTOS, simulators, debuggers, programmers, etc. Based on open-source NetBeans platform Runs under Windows, Linux, and Mac OS X Slide 2

22 MPLAB X IDE (Integrated Development Environment) Integrates Microchip and third party tools Compilers, Assemblers In-Circuit Debuggers Simulators Emulators Code Editor Programmers Slide 22

23 The MPLAB X Ecosystem In-Circuit Debug Tool Feature Comparison Feature PICkit 3 ICD 3 REAL ICE USB Speed Full High High Power to Target HW Breakpoints SW Breakpoints Stopwatch Trace Data Capture Logic Probe / Trigger Slide 23

24 MPLAB ICD 2 In Circuit Debugger & Programmer MPLAB ICD 2 is a low cost, real-time debugger and programmer. Reads and Writes Program, Data and E 2 memory Real time debugging Step through instructions while monitoring data memory registers Programs configuration bits Slide 24

25 PICDEM 2 Plus Board 9V to 5V regulator LEDs Analog Pot 6 x 2 LCD Module RS232 Connecto r ICD Connecto r Piezo Buzzer I 2 C Based Temp Sensor 8, 28 and 4- pin DIP sockets Push button Switches Slide 25

26 XC8 C Compiler with MPLAB X 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28 26

27 MPLAB XC Compilers Unified Compiler Platform MPLAB XC8 8-bit Architecture MPLAB XC6 6-bit Architecture MPLAB XC32 32-bit Architecture MPLAB XC Suite All PIC MCUs and dspic DSCs Straightfoward line of C compilers that provide the best execution speed and code size for all PIC MCUs and dspic DSCs Slide 27

28 OPTIMIZATIONS Compiler Editions Compiler License Cost Evaluation PRO Optimizations for 6 days then Free Compiller All devices and memory supported Commercial Use Permitted XC8 Pro XC8 Standard Free Optimized All devices and memory supported Commercial Use Permitted Workstation $995 Network $,295 Workstation $495 Network $595 Standard Optimized 2-25% better than Free All devices and memory supported Commercial Use Permitted PRO Optimized ~5% better than Free All devices and memory supported Commercial Use Permitted FREE FREE $495 $995 Slide 28

29 Using C Language Advantages Faster Development Cycle Algorithms more easily written in C Easier to Develop Code Bank Switching and Paging handled by compiler Easier to Debug Code C s implementation of control structures and decision branches well tested Disadvantages Higher Memory Utilization C Takes more Program Memory space than Assembly in most applications Program Execution Time More instructions per task = more time per task Execution time of C programs needs to be verified Time critical tasks are typically coded in assembly Slide 29

30 Configuring Registers with PICC INTCON (Interrupt Control Register) GIE PEIE TMRIE INTE RBIE TMRIF INTF RBIF bit 7 bit Example: Enable Global Interrupts and Timer Interrupts 3 ways to do this. INTCON = xa; /* write all bits in INTCON * register using hex */ 2 INTCON = b; //write all bits using binary 3 GIE = ; //set the Global Interrupt bit TMRIE = ; //set the Timer Interrupt bit Slide 3

31 Mixing Assembly with C Assembly code can be inserted into C code 2 ways to do this. asm( movlw h ); asm( movwf 2h ); // Insert one assembly // instruction at a time 2 #asm movlw h movwf 2h #endasm // Insert a block of // instructions using the // #asm directive Slide 3

32 Manipulating C Objects in Assembler #include <xc.h> Defines an 8-bit register called var unsigned char var; void main (void) { TRISB = X; var = ; Underscore needed in order to #asm manipulate in assembly rlf _var rlf _var //move 2 bits to the left #endasm } PORTB = var; while(); Slide 32

33 Lab : My First Project 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28 33

34 Lab : XC8 and MPLAB IDE Goals: Work with XC8 and MPLAB X IDE environment to create a C-Based Project To Do: Follow the slides Expected Result: Successfully build the project and program the device LED RB should blink Slide 34

35 Lab : PICC and MPLAB X IDE Create and name a new project Slide 35

36 Double Click Current Compiler Lab : XC8 and MPLAB X IDE Select the Language Toolsuite Select XC8 Compiler Slide 36

37 Lab : XC8 and MPLAB X IDE Select the device for this project Click Configure and Select Device Slide 37

38 Lab : PICC and MPLAB IDE Set the Core Configuration Bits Set all Configuration Bit as shown Click Generate Source Code to Output Slide 38

39 Lab : XC8 and MPLAB X IDE Header files and MPLAB MPLAB IDE does not use files placed in the Header Files folder when building. Consider it a means to document a project's dependency on a header file, and a convenient method to access these files. If you want to use header files, they must be included in the source code. Slide 39

40 Modify main.c file void main(void) { unsigned int i; Lab : XC8 and MPLAB X IDE /* Configure the oscillator for the device */ ConfigureOscillator(); /* Initialize I/O and Peripherals for application */ InitApp(); PORTB = x; ADCON = x6; TRISB = x; } while() { /* TODO <INSERT USER APPLICATION CODE HERE> */ RB = ; for(i=;i<xfff;i++); RB = ; for(i=;i<xfff;i++); } Slide 4

41 Lab : XC8 and MPLAB X IDE Building the project Slide 4

42 Interrupts 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28 42

43 Polling and Interrupts Often we would like the processor to perform a task if a specific event occurs Two methods to check if this event has occurred: Polling: Continuously check for event at various points in the code Interrupts: INTERRUPTS the Main program and starts an Interrupt Service Routine when an event occurs Slide 43

44 Polling Example RA = ; //Set bit of PORTA while(rb == ); //Loop while bit //of PORTB is RA = ; //Clear bit of PORTA RA = Set PORTA bit Test (poll) for a on PORTB bit Clear PORTA bit if RBO = No RB =?? Yes RA = Slide 44

45 Interrupt Example //=====Main Routine=========== void main (void) { } //==Interrupt Service Routine== void interrupt isr (void) { } Main program code Interrupt Service Routine (ISR) ISR completed Main( ) program execution Execute ISR( ) no interrupt interrupt flag set Slide 45

46 Enabling Interrupts Processor must be told that interrupts will be used A number of registers with interrupt enable bits do this: Interrupt Control (INTCON) Peripheral Interrupt Enable (PIE) Peripheral Interrupt Enable 2 (PIE2) Slide 46

47 TMR2IE TMR2IF Timer External interrupt Change on a PORTB pin TMRIE TMRIF INTE INTF RBIE RBIF Interrupt Logic Bits located in the INTCON register Interrupt GIE ADIE ADIF Other peripherals PEIE Global interrupt enable Peripheral interrupt enable Slide 47

48 bit 7 INTCON Register (Core Interrupts) bit GIE PEIE TMRIE INTE RBIE TMRIF INTF RBIF Enable Bits GIE PEIE TMRIE INTE RBIE Description Global Interrupt Enable Peripheral Interrupt Enable Timer Interrupt Enable External Interrupt Enable PORTB change Interrupt Enable Must be set to use any interrupts Must be set to use any peripheral interrupts Flags will set even if interrupts aren t enabled! Flag Bits TMRIF INTF RBIF Description Timer Overflow Interrupt Flag RB/INT External Interrupt Flag PORTB Change Interrupt Flag Slide 48

49 Enabling a Core Interrupt (External Interrupt) void interrupt isr (void) { //clear External Interrupt //flag to enable interrupts //after this ISR INTF = ; } //<ISR code> prog mem address prog mem address Program Counter Stack void main (void) { <code to set up PORTB > // initialize INTCON INTCON = b; //enable an external //interrupt on the INT pin INTE = ; //enable global interrupts GIE = ; INTCON GIE GIE bit automatically cleared by hardware INTE GIE bit automatically set when ISR completes INTF Interrupt detected on RB/INT pin } while() ; //loop forever Slide 49

50 Peripheral Interrupts Two registers ENABLE interrupts for peripherals Peripheral Interrupt Enable (PIE) Peripheral Interrupt Enable 2 (PIE2) Two registers display peripheral REQUESTS for an interrupt (Flags) Peripheral Interrupt Request (PIR) Peripheral Interrupt Request 2 (PIR2) Flags will set even if interrupts are not enabled!! Slide 5

51 PIE and PIR Registers* PIE Register (Peripheral Interrupt Enables) ADIE RCIE TXIE SSPIE CCPIE TMR2IE TMRIE PIR Register (Peripheral Interrupt Requests) ADIF RCIF TXIF SSPIF CCPIF TMR2IF TMRIF Enable ADIE RCIE TXIE SSPIE CCPIE TMR2IE TMRIE Flag ADIF RCIF TXIF SSPIF CCPIF TMR2IF TMRIF Condition ADC conversion complete AUSART receive buffer is full AUSART transmit buffer is full I 2 C or SPI Interrupt Timer register capture or compare match Timer2 value and PR2 period value match Timer register has overflowed *Check individual data sheets for bit locations. Slide 5

52 PIE2 and PIR2 Registers* PIE2 Register (Interrupt Enables) OSCFIE C2IE CIE EEIE BCLIE ULPWUIE CCP2IE PIR2 Register (Interrupt Flags) OSCFIF C2IF CIF EEIF BCLIF ULPWUIF CCP2IF Enable OSCFIE C2IE CIE EEIE BCLIE ULPWUIE CCP2IE Flag OSCFIF C2IF CIF EEIF BCLIF ULPWUIF CCP2IF Condition System Oscillator Failed Comparator2 output changed Comparator output changed Write operation completed Bus collision occurred in MSSP I 2 C mode Wake-up condition occurred Timer Capture or Compare match occurred *Check individual data sheets for bit locations. Slide 52

53 Enabling a Peripheral Interrupt (Timer) void interrupt isr (void) { //Clear the interrupt flag TMRIF = ; // <ISR code> } //ISR completes void main (void) { //clear the interrupt flag TMRIF = ; //enable Timer interrupt TMRIE = ; //Enable peripheral and //global interrupts PEIE = ; GIE = ; // <code to set up Timer> while(); //loop forever } while(); address while(); address INTCON GIE PEIE PIE PIR GIE bit automatically cleared by hardware GIE bit automatically set when ISR completes Program Counter Stack TMRIE TMRIF Slide 53 Interrupt detected on RB/INT pin

54 Interrupt Latency Interrupt Latency: Time from interrupt event to execution of instruction at address 4h Synchronous interrupts (typically internal) latency is 3 instruction cycles (Tcy) Asynchronous interrupts (typically external) latency is 3 4 instruction cycles ISR main() CPU EXECUTION TRACE Slide 54

55 Interrupt Priority Mid-Range PIC microcontrollers treat all Interrupts with the same priority The user must do the following: Determine source of interrupt Determine the order in which the interrupts are serviced. Slide 57

56 Interrupt Priority Example void interrupt isr (void) { //Check various interrupt flags and respond //accordingly //If the RBIF flag is set, then perform the PORTB_ISR subroutine if (RBIF) PORTB_ISR ( ); //If TMR2IF flag is set, then perform the Timer2_ISR subroutine if (TMR2IF) Timer2_ISR ( ); //If the TMRIF flag is set, then perform the Timer_ISR subroutine if (TMRIF) Timer_ISR ( ); } Slide 58

57 External Interrupt Hands on Lab 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28 59

58 External Interrupts The objective of this is to: Learn how to set up and enable an external interrupt on the Mid-Range PIC Become more familiar with the MPLAB IDE, the PICdem2 Plus and the ICD 2 Write 3 lines of code Build and debug the project Slide 6

59 External Interrupt Lab Overview Interrupt Vector Call debounce delay function Increment Count variable Clear IF Return to Main Main Program Clear Variables Initialize PORTB (RB) for S3 input Enable Interrupts No Operation NOP Slide 6

60 Lab Specifics The S3 switch is connected to the RBO/INT pin on PORTB The push_count register will display the # of times S3 has been pushed. Use MPLAB and the ICD to set a breakpoint in the code to view the changing value of the register named push_count Slide 62

61 What you need to know The function of the INTCON register bits Jumper J6 must be removed in order for the INTE pin to work A subroutine called debounce is given masks the mechanical bouncing of S3 How to setup break points and a Watch Window in MPLAB Slide 63

62 External Interrupt Lab Solution Slide 64

63 Peripherals 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28 65

64 Mid-Range Family Peripherals I/O Ports Timers (,, 2) Capture/Compare/PWM Comparators Analog-to-Digital Converter AUSART I 2 C and SPI Serial Interface Slide 66

65 Input/Output (I/O) Ports 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28 67

66 I/O Overview Up to 35 bi-directional Input/Output pins some multiplexed with peripheral functions After Reset: Analog capable pins come up as Analog Digital I/O pins come up as Digital Input Direct, single cycle bit manipulation High drive capability 25mA source or sink Slide 68

67 PORTx and TRISx Registers Every PORT (A, B, C, D, E) will have a corresponding direction register TRISx PORTB Register RB7 RB6 RB5 RB4 RB3 RB2 RB RB Data Configures Data Direction PORTB Tri-State Register (TRISB) TRISB7 TRISB6 TRISB5 TRISB4 TRISB3 TRISB2 TRISB TRISB = corresponding PORTB pin is an INPUT = corresponding PORTB pin is an OUTPUT Slide 69

68 Configuring Analog Inputs as Digital I/O s with digital and analog capabilities default to analog on reset Slide 7

69 Configuring Analog Inputs as Digital Two ways to configure Analog inputs as Digital ) Analog Select Registers (ANSEL and ANSELH) For devices with > 8 analog pins Analog Select Register (ANSEL) ANS7 ANS6 ANS5 ANS4 ANS3 ANS2 ANS ANS Analog Select High Register (ANSELH) ANS3 ANS2 ANS ANS ANS9 ANS8 = Pin assigned as Analog Input = Digital I/O OR 2) ADC Control register (ADCON) For devices with 8 or less analog pins ADC Control Register (ADCON) Port Configuration Bits ADFM ADCS2 PCFG3 PCFG2 PCFG PCFG Slide 7

70 Configuring Analog Inputs as Digital PCFG <3:> AN7 AN6 AN5 AN4 AN3 AN2 AN Vdd AN ADC Control Register (ADCON) Port Configuration Bits ADFM ADCS2 PCFG3 PCFG2 PCFG PCFG Slide 72

71 Initializing Digital I/O with ADCON register (PIC6F877A) Example: Initializing PORTB bits RB<7:4> as digital inputs and RB<3:> as digital outputs //---configure PORTB for digital PORTB = x; //Clear PORTB ADCON = x6; //Configure as all digital //---Set up direction of each PORTB pin TRISB = b; // = input, = output Slide 73

72 Initializing Digital I/O with ANSEL and ANSELH registers (PIC6F887) Example: Initializing PORTB bits RB<7:4> as digital inputs and RB<3:> as digital outputs //---configure PORTB for digital PORTB = x; //Clear PORTB ANSLEH = x; //Configure as all digital ANSEL = x; //---Set up direction of each PORTB pin TRISB = b; // = input, = output Slide 74

73 PORTB Interrupt & Weak Pull-Up Options All PORTB pins have Interrupt-on-Change and Weak Pull-Up options Weak Pull-Up PORTB Register (WPUB) WPUB7 WPUB6 WPUB5 WPUB4 WPUB3 WPUB2 WPUB WPUB = Pull-up enabled = Pull-up disabled Interrupt-On-Change PORTB Register (IOCB) IOCB7 IOCB6 IOCB5 IOCB4 ICOB3 IOCB2 IOCB IOCB = Interrupt-on-change enabled = Interrupt-on-change disabled Interrupt Control Register (INTCON) HIGH LOW GIE PEIE TMRIE INTE RBIE TMRIF INTF RBIF Devices without WPUB register use RBPU bit in OPTION register Devices without IOCB rely on RBIE bit in INTCON RBIF *PORTB must first be read/written and then RBIF can be cleared in software RB3 RB4 Slide 75

74 Timers 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28 76

75 Timers can be used as: A Timer To Time an Event on an Input To Generate an output clock or waveform Event counter Count an event Timer Applications TMR Start Timing Stop Timing Slide 77

76 Timer Comparison TIMER TIMER TIMER2 SIZE OF REGISTER 8-bits (TMR) 6-bits (TMRH:TMRL) 8-bits (TMR2) CLOCK SOURCE (Internal) Fosc/4 (instruction clock) Fosc/4 (instruction clock) Fosc/4 (instruction clock) CLOCK SOURCE (External ) TCKI pin TCKI pin or Timer oscillator (TOSC) None CLOCK SCALING AVAILABLE (Resolution) Prescaler 8-bits (:2 :256) Prescaler 3-bits (, 2, 4, 8) Prescaler (:,:4,:8) Postscaler (: :6) Interrupt Event and Flag Location On overflow FFh h (TMRIF in INTCON) On overflow FFFFh h (TMRIF in PIR) TMR2 matches PR2 (TMR2IF in PIR2) CAN WAKE PIC FROM SLEEP? NO YES NO Slide 78

77 Timer Operation DATA BUS Fosc/4 TCKI pin scaled clock synchronize TMR Watchdog Timer OPTION register prescaler WDT out PS2 PS PS TMR RATE :2 :4 RBPU INTEDG TOCS TOSE PSA PS2 PS PS :8 :6 Prescaler Rate Select Bits TMR Clock Source Select = TOCK, = Fosc/4 Source Edge Select Prescaler Assignment = prescaler assigned to WDT = prescaler assigned to Timer = increment TMR on high-to-low transition = increment TMR on low-to-high transition :32 :64 :28 :256 Slide 79

78 Timer Operation DATA BUS Fosc/4 TCKI pin scaled clock synchronize TMR Watchdog Timer prescaler WDT out If the external clock source (TOCKI) is used it will be synchronized to the internal clock Timer is readable or writeable INTCON register TMRIF Timer interrupt flag is set on TMR roll-over (FF to ) Slide 8

79 //Make sure the Timer count //register (TMR) is clear TMR = X; Timer Initialization //Disable the Timer interrupt //and clear the flag bit TIE = ; TIF = ; /*Setup the following in the OPTION_REG Timer increment from internal clock with a prescaler of :6*/ OPTION = b; /*The TMR interrupt is disabled, do polling on the Timer overflow flag bit*/ While (!TIF); <continue> TMR INTCON TMRIE OPTION_REG TMRIF TOCS Selects Timer Clock Source (External or Internal) Timer Incrementing This interrupt flag will set on Timer overflow even if interrupts are disabled PSA Prescaler Assignment (WDT or TMR) PS<2:> Prescaler value = :6 Slide 8

80 Timer Operation TOSI TOS T OSC prescaler synchronize TCKI pin Fosc/4 Timer Control Register (TCON) TMRH TGINV TMRGE TCKPS TCKPS TOSCEN TSYNC TMRCS TMRON TMRL Enable TMRON TCKPS TCKPS scale :8 :4 :2 : LP Oscillator Enable = TOSC selected = TCKI can be used Clock Source Select = External (TCKI) = Internal (F OSC /4) Timer On = Enable Timer Slide 82

81 Timer Operation TOSI TOS T OSC prescaler synchronize TCKI pin Fosc/4 Timer Control Register (TCON) TMRH TGINV TMRGE TCKPS TCKPS TOSCEN TSYNC TMRCS TMRON TMRL Enable TMRON Timer Gate Enable and Timer Gate Invert are available on some devices Timer External Clock Input Synchronization = do not synchronize external clock input = synchronize external clock input with internal clock (Fosc/4) Slide 83

82 Timer Interrupt Setup TMRH TMRL void main (void) { //Clear the Timer interrupt flag TMRIF = ; //Enable Timer interrupt TMRIE = ; Overflow sets flag and starts ISR PIR PIE //Enable Global and Peripheral Interrupts PEIE = ; GIE = ; } INTCON GIE PEIE TMRIF TMRIE Slide 84

83 Timer Initialization //Make sure the TMR registers are clear TMRH = X; TMRL = X; //Make sure the TMRIF flag in PIR //is cleared TMRF = ; /*Setup TCON register for internal clock with :8 prescaler, Timer is stopped and T osc is disabled*/ TCON = b; //Start Timer incrementing TMRON = ; TMRH //The TMR interrupt is disabled, do polling //on the TMRIF overflow bit while(!tmrif); Input clock prescale bits (TCKPS<:>) //Continue TMRL PIR (Peripheral Interrupt Request) TCON (Timer Control) TMRIF Slide 85 Timer oscillator enable bit (TOSCEN) TMRON Clock source select bit (TMRCS)

84 Timer Lab 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28 86

85 Timer Lab Objective of this lab is to become familiar with the operation of Timer AND To gain experience enabling Peripheral Interrupts Slide 87

86 Lab Overview Interrupt Vector Save Context Clear IF Reload Timer Toggle LED Main Program Initialize PORTB Initialize Timer clock source and pre-scaler: Timer interrupts every, Instruction cycles 5 th Int.? YES Toggle LED 3 Restore Context NO Enable Timer, Global and Peripheral Interrupts NOP Main Loop Retfie Slide 88

87 Lab Specifics The code for the lab is in C:\RTC\MCU_2\Lab2-TMR Within LAB2-TMR.c complete the following Set Timer clock source to Fosc/4 Set Timer pre-scaler to 2 Load Timer with x3cb (65,356 5,) Start Timer Enable Timer, Global and Peripheral Interrupts Slide 89

88 What you need to know Register Operations of INTCON, TCON, TMRH, TMRL and PIE With a value of x3cb and a pre-scaler of 2, Timer will overflow every, cycles The interrupt vector code to toggle the LEDs has been provided Place Jumper J6 ON Slide 9

89 Timer Solution Slide 9

90 Question: Answer: Lab Questions Was Timer still running during the time it took to service the Interrupt? Yes Question: Answer: What effect did this have on the value to be placed to reload TMRL and TMRH? Everything to be precise the latency of reloading Timer should be considered. Slide 92

91 Timer2 Operation Fosc/4 TOUTPS3 TOUTPS2 TOUTPS TOUTPS SCALE Prescaler :, :4, :6 TMR2 :8 PR2 Timer2 Control Register (T2CON) :6 :7 :9 COMPARATOR : :2 :3 :4 :5 :6 TOUTPS3 TOUTPS2 TOUTPS TOUTPS TMR2ON T2CKPS T2CKPS : :2 :3 :4 :5 : TMR2 OUTPUT Postscaler : :6 Timer2 clock prescaler Timer2 clock postscaler T2CKPS Timer2 ON = Timer2 enabled X :6 Slide 94 T2CKPS Scale : :4

92 Timer2 Operation Fosc/4 Prescaler :, :4, :6 TMR2 Start Timer2 Counting TMR2 OUTPUT COMPARATOR Postscaler : :6 Load Period Register Timer2 Control Register (T2CON) PR2 PIR TMR2IF TOUTPS3 TOUTPS2 TOUTPS TOUTPS TMR2ON T2CKPS T2CKPS Flag set on first match with postscaler = : Timer2 ON = Timer2 enabled Slide 95

93 /*Disable the Timer2 interrupts in the PIE register. Make sure the Timer2 interrupt flag in PIR is cleared. */ TMR2IE = ; TMR2IF = ; /*Setup T2CON register for: Postscaler = :5 Prescaler = :6 Timer2 is off */ T2CON = b; //Make sure the TMR2 register is clear TMR2 = X; //Load the period register PR2 = b; //Start Timer2 incrementing TMR2ON = ; Timer2 Initialization TMR2 (Timer2 Counter) PR2 (Period Register Timer2) PIE (Peripheral Interrupt Enable) PIR (Peripheral Interrupt Request) T2CON (Timer2 Control) Flag is set Timer2 Incrementing TMR2IE TMR2IF //The Timer2 interrupt is disabled, //do polling on the interrupt flag while(!tmr2if); Postscaler = :5 (TOUTPS<3:>) TMR2ON Prescaler = :6 (T2CKPS<:>) Slide 96

94 Capture/Compare/PWM Module 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28 97

95 Capture/Compare/PWM (CCP) Overview Capture Times the duration of an external event using an input CCP pin MODE Timer Resource Compare Capture Timer Changes an output pin or generates an interrupt Compare Timer when a specific amount of time has passed PWM Timer 2 Pulse Width Modulation (PWM) Creates a reconfigurable, steady duty-cycle, square wave output at a defined frequency Provides enhanced features for various bridge connectivity Slide 99

96 CCP Control Register CCP Control Register (CCPCON) PM PM CCPX CCPY CCPM3 CCPM2 CCPM CCPM CCPxM3 BIT CCPM<3:> CCP<X:Y> PM<:> CCPxM2 FUNCTION CCPxM CCPxM CCP Mode Selected CCP Mode Select Bits configure the module as Input Capture, Capture/Compare/PWM off (resets CCP module) Output Compare, or PWM PWM duty cycle 2 LSB s (8 MSB s located in CCPRL) These PWM output configuration bits are Unused available (reserved) for Enhanced CCP (ECCP) modules only. They provide Capture mode, half-bridge every falling or edge full-bridge output steering control. Unused (reserved) Compare mode, toggle output on match Capture mode, every rising edge Capture mode, every 4th rising edge Capture mode, every 6th rising edge Compare mode, set output on match Compare mode, clear output on match Compare mode, generate software interrupt on match Compare mode, trigger special event x x PWM mode Slide

97 Capture Mode CCPx Prescaler, 4, 6 Edge Detect and TMRH CCPxM3 CCPxM2 CCPxM CCPxM MODE CCPxIF in PIRx TMRL Capture every falling Single edge Buffered Capture every rising edge System Clock (Fosc) Capture every 4 th rising edge CCPRxH CCPRxL Capture every 6 th rising edge PM PM CCPX CCPY CCPM3 CCPM2 CCPM CCPM CCPxCON Slide 3

98 Capture Initialization ;Turn off CCP module CCPCON = x; ;Make sure Timer is off TMRON = ; ;Clear Timer registers TMRH = x; TMRL = x; ;Disable all interrupts for CCP CCPIF = ; CCPIE = ; ;Set CCP pin for input TRISC2 = ; CCP Pin 43 2 th rd nd st Rising Edge Detected!! ;Set Capture for every 4 th rising edge CCPCON = b ; ;Start Timer incrementing TMRON = ; ;Test the interrupt flag for capture while (!CCPIF); TMRH TMRL CCPRH CCPRL PIR CCPIF CCPCON TCON Current Timer Value TIMER INCREMENTING!! Captured! TMRON Slide 4

99 Compare Mode TMRH TMRL CCPxIF in PIRx CCPxM3 CCPxM2 CCPxM CCPxM MODE COMPARATOR Set output on match (CCPxIF is set) Does TMRH:TMRL = Clear output OUTPUT on match (CCPxIF is set) CCPRxH:CCPRxL YES Generate software LOGIC interrupt on CCPx match (CCPxIF is set CCP pin unaffected) CCPRxH?? CCPRxL NO Trigger special event (CCPxIF is set, CCP resets TMR or TMR2 and starts an A/D conversion if enabled) Special Event Trigger PM PM CCPX CCPY CCPM3 CCPM2 CCPM CCPM Slide 6

100 Compare Initialization //Turn off the CCP module CCPCON = x; //Turn off Timer TMRON = ; //Clear Timer result registers TMRH = x; TMRL = x; //Disable CCP interrupt and make sure //its flag is clear CCPIE = ; CCPIF = ; //Make CCP pin output TRISC2 = ; //Initialize Compare to set output on match CCPCON = b; //Load compare value into CCPRH:CCPRL CCPRH = b; CCPRL = x; //Start Timer incrementing TMRON = ; //Test CCPIF for Timer match with CCPRx While (!CCPIF) TMRH TMRL CCPRH CCPRL TCON CCPCON PIR TMRON CCPIF Slide 7

101 PWM Mode Generates a Pulse-Width Modulated (PWM) signal on the CCP and CCP2 pins Duty cycle, period and resolution determined by the following registers Register PR2 T2CON CCPRxL CCPxCON Description Period Register Timer2 Control Duty Cycle Register CCP Control Register Slide 8

102 PWM Operation CCPRL CCPRH TMR2 COMPARATOR 8 CCPX:CCPY bits in CCPCON Period Start R Latch S CCP Output Pin CCP pin COMPARATOR PR2 8 TMR2 Reset to s Determines Period TMR2 is concatenated with 2 bits from F OSC, or 2 bits from Prescaler to create a bit time base Slide 9

103 PWM Operation CCPRL CCPRH TMR2 Determines Duty Cycle Double Buffer COMPARATOR COMPARATOR PR2 8 8 CCPX:CCPY bits in CCPCON Period Start R Latch S CCP Output Pin CCP pin TMR2 is concatenated with 2 bits from F OSC, or 2 bits from Prescaler to create a bit time base Slide

104 PWM Operation CCPRL CCPRH TMR2 COMPARATOR COMPARATOR PR2 8 8 CCPX:CCPY bits in CCPCON R Latch S Period Period Start CCP Output Pin CCP pin TMR2 is concatenated with 2 bits from F OSC, or 2 bits from Prescaler to create a bit time base Slide

105 PWM Operation CCPRL CCPRH TMR2 Determines Duty Cycle Double Buffer COMPARATOR 8 CCPX:CCPY bits in CCPCON Period Start R Latch S Period CCP Output Pin CCP pin Period 2 COMPARATOR PR2 8 TMR2 Reset to s TMR2 is concatenated with 2 bits from F OSC, or 2 bits from Prescaler to create a bit time base Slide 2

106 //Turn off CCP pin by making it an input TRISC2 = ; //Turn off Timer2 TMR2ON = ; //Clear Timer2 TMR2 = x; PWM Initialization //Set up Period and Duty Cycle PR2 = b; //Load a Period Value CCPRL = b; //Load a Duty Cycle Value //Configure CCP module for PWM // and LSB s of Duty Cycle = b CCPCON = b; //Turn CCP pin back on (make it an output) TRISC2 = ; //Start the PWM by turning on Timer2 //Configure Prescaler and Postscaler to :) T2CON = b; TMR2 PR2 CCPRL CCPCON T2CON duty cycle LSBs DCB<:> PWM Mode CCPM <3:> Prescaler bits TOUTPS<3:> TMR2ON Prescaler bits T2CKPS<:> Slide 3

107 Pulse Width Modulation (PWM) Lab 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28 4

108 PWM Lab Objectives Become familiar with the CCP module configuration and operation in PWM mode Gain additional exposure to Timer2 configuration Slide 5

109 PWM Lab Overview The PWM waveform is output on the CCP pin (RC2) that will emit a tone on the PICdem2 plus onboard buzzer. When the lab is completed, a 5% duty cycle at a period of 256/(Fosc/4) will drive the buzzer Slide 6

110 PWM Lab Overview Main Code Load PR2 value Set up RC2 as output pin Load CCPRL for 5% duty cycle Configure CCP as 8-bit PWM Turn on Timer2 w/ : pre scaler NOP Slide 7

111 PWM Lab Specifics Code for the lab is in C:\RTC\MCU_2\Lab4-PWM Complete the following sections Configure PORTC pin 2 ( CCP) as an output Set CCP in PWM mode Clear CCPX and CCPY (8-bit PWM) Configure Timer2 with : pre-scaler Slide 8

112 What you need to know The code to load PR2 (Timer2) and to set a 5% duty cycle has been provided. These values can be seen in the code The CCP pin is RC2 (Pin 2 of PORTC) on the PIC6F877 Registers needed to complete this lab are: TRISC T2CON CCPCON Slide 9

113 PWM Lab Solution Slide 2

114 PWM Lab Questions Question: Why didn t we have to enable the interrupts for the PWM to work? Answer: PWM will run concurrently with the PICmicro MCU without slowing the processor down Slide 2

115 Comparators 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28 22

116 Comparator Overview Comparator Module: Compares analog input voltage to a reference and outputs a digital result Vref Analog Input (Vin) Reference Voltage (Vref) Vin + Vout Comp - Output (Vout) Slide 23

117 Comparator Reference Voltage Voltage Reference can be either: External from a device pin Internally generated with the Voltage Reference Module Provides 6 selectable voltages from to 75% of VDD Some devices can also scale V REF+ and V REF- Some devices also have a fixed reference (.6V) Independent of VDD V REF+ VRSS = 8R R R R R VRR VRSS = V DD CV REF 5 8R To Comparators and ADC Module CV REF VROE VREN 4 VR<3:> VRSS = VRSS = V REF- Slide 24

118 Comparator Interrupts An Interrupt occurs when the comparator output changes Some devices share one flag for both comparators Some devices have independent flags Must read the comparator output before clearing interrupt flags Outputs found in the comparator control register (CMCON or CMxCON Slide 25

119 Comparators and Sleep Mode Comparators remain active in Sleep A Comparator output change will wake-up core After wake-up, the instruction following the SLEEP instruction or an Interrupt Service Routine (ISR) is executed Slide 26

120 Analog-to-Digital Converter (ADC) 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28 27

121 ADC Overview Analog-to-Digital Converter Module Converts analog input signal into an 8 or -bit binary value Selectable internal or external reference voltage Interrupt can be generated after conversion is completed The interrupt can wake the PICmicro from SLEEP Analog Input ADC Digital Output Slide 28

122 ADC Control Registers The ADC implements two control ADCON registers ADCON and ADCON F OSC/2 Devices with > 8 analog inputs do not have same bits shown below ADC Control Register (ADCON) ADCS ADCS CHS2 CHS CHS GO/DONE ADON BIT ADCS:ADCS <ADCS2> FUNCTION F OSC to T AD Conversion Select bits Use with ADCS2 in ADCON ADCON <ADCS:ADSC> F OSC to T AD Clock Conversion F OSC/8 F OSC/32 FRC (ADC RC Osc) F OSC/4 F OSC/6 F OSC/64 FRC (ADC RC Osc) CHS2:CHS GO/DONE ADON Analog Channel Select bits = A/D Conversion in progress = A/D Conversion is completed Enables the ADC module Slide 3

123 ADC Control Registers The ADC implements two control registers ADCON and ADCON Devices with > 8 analog inputs do not have same bits shown below ADC Control Register (ADCON) ADFM ADCS2 PCFG3 PCFG2 PCFG PCFG BIT ADFM ADCS2 PCFG<3:> FUNCTION ADC Result Registers Format bit = Right Justified, = Left Justified F OSC to T AD Conversion Select bit Use with ADCS<:> in ADCON Port Configuration Bits Configures I/O as analog or digital Slide 3

124 ADC Result Registers bit ADC result in is placed in two registers ADRESH and ADRESL Left or Right Justified Determined by Format Select bit (ADFM) in ADCON register ADRESH MSB ADRESL LSB Left Justified (ADFM = ) ADRESH MSB ADRESL LSB Right Justified (ADFM = ) Slide 32

125 ADC Operation PCFG <3:> F OSC AN7 AN6 AN5 AN4 Conversion clock scaler AN3 AN2 AN Vdd AN AN AN AN2 AN3 AN4 AN5 AN6 AN7 F OSC to T AD Conversion ADCON Holding Capacitor ADCS ADCS CHS2 CHS CHS GO/DONE ADON ADCON ADFM ADCS2 PCFG3 PCFG2 PCFG PCFG ADFM Channel Select V REF+ pin ADRESH ADRESL Left Justified Right Justified V REFpin Slide 34 T AD Start Conversion Complete GO/DONE ADC Vss Port Config Bits

126 Input Signal Acquisition Time Acquisition Time Conversion Time time (ADRESH : ADRESL) VC VIN ADC Acquisition Time allows Hold Capacitor to fully charge to VIN SOURCE time RS < k CHOLD 2pF + VC - V REF- or VSS Acquisition Time is determined by Pin Capacitance and Source impedance (recommend <k ) V Slide 35

127 Conversion Time (ADRESH : ADRESL) ADC Result VC Acquisition Time Acquisition Conversion Time time VIN time ADC Conversion Clock cycles (TAD) ADC time CHOLD 2pF + VC - V REF- or VSS Slide 36

128 ADC Lab Question Question: Instead of waiting for TMR2IF to be set in the main program, could we start the ADC from within an interrupt routine? Answer: YES Slide 37

129 Midrange Peripherals Wrap Up 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28 57

130 Peripherals Class Wrap-up We created a C-project in MPLAB that used HITECH s PICC Lite compiler We learned the following peripherals: I/O ports Interrupt structure and processing Timers (Timer, Timer, Timer2) CCP Module ( Output Compare, Input Capture, PWM) Comparators and Analog-to-Digital Converters Voltage Reference AUSART Serial Port I 2 C using the MSSP module Slide 58

131 Resources Visit and follow the links for: 24/7 technical support Application Notes Web Seminars Code examples Datasheets and Much More! Slide 6

132 Thank You!! 26 Microchip Technology Incorporated. All Rights Reserved. 2ASP Rev. January Slide 28 6

133 Trademarks The Microchip name and logo, the Microchip logo, Accuron, dspic, KeeLoq, microid, MPLAB, PIC, PICmicro, PICSTART, PRO MATE, PowerSmart, rfpic and SmartShunt are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. AmpLab, FilterLab, Migratable Memory, MXDEV, MXLAB, SEEVAL, SmartSensor and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A. Analog-for-the-Digital Age, Application Maestro, dspicdem, dspicdem.net, dspicworks, ECAN, ECONOMONITOR, FanSense, FlexROM, fuzzylab, In- Circuit Serial Programming, ICSP, ICEPIC, Linear Active Thermistor, Mindi, MiWi, MPASM, MPLIB, MPLINK, MPSIM, PICkit, PICDEM, PICDEM.net, PICLAB, PICtail, PowerCal, PowerInfo, PowerMate, PowerTool, REAL ICE, rflab, rfpicdem, Select Mode, Smart Serial, SmartTel, Total Endurance, UNI/O, WiperLock and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. SQTP is a service mark of Microchip Technology Incorporated in the U.S.A. All other trademarks mentioned herein are property of their respective companies. Slide 62

EE6008-Microcontroller Based System Design Department Of EEE/ DCE

EE6008-Microcontroller Based System Design Department Of EEE/ DCE UNIT- II INTERRUPTS AND TIMERS PART A 1. What are the interrupts available in PIC? (Jan 14) Interrupt Source Enabled by Completion Status External interrupt from INT INTE = 1 INTF = 1 TMR0 interrupt T0IE

More information

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002. Semester 2. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J2. Time allowed: 3 Hours

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002. Semester 2. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J2. Time allowed: 3 Hours UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 Semester 2 Year 2 MICROCONTROLLER SYSTEMS Module Code: EEE305J2 Time allowed: 3 Hours Answer as many questions as you can. Not more than TWO questions

More information

EEE111A/B Microprocessors

EEE111A/B Microprocessors EEE111A/B Microprocessors Revision Notes Lecture 1: What s it all About? Covers the basic principles of digital signals. The intelligence of virtually all communications, control and electronic devices

More information

Lecture (04) PIC16F84A (3)

Lecture (04) PIC16F84A (3) Lecture (04) PIC16F84A (3) By: Dr. Ahmed ElShafee ١ Central Processing Unit Central processing unit (CPU) is the brain of a microcontroller responsible for finding and fetching the right instruction which

More information

PIC 16F84A programming (II)

PIC 16F84A programming (II) Lecture (05) PIC 16F84A programming (II) Dr. Ahmed M. ElShafee ١ Introduction to 16F84 ٣ PIC16F84 belongs to a class of 8-bit microcontrollers of RISC architecture. Program memory (FLASH) EEPROM RAM PORTA

More information

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J1. Time allowed: 3 Hours

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J1. Time allowed: 3 Hours UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT Year 2 MICROCONTROLLER SYSTEMS Module Code: EEE305J1 Time allowed: 3 Hours Answer as many questions as you can. Not more than TWO questions

More information

Instuction set

Instuction set Instuction set http://www.piclist.com/images/www/hobby_elec/e_pic3_1.htm#1 In PIC16 series, RISC(Reduced Instruction Set Computer) is adopted and the number of the instructions to use is 35 kinds. When

More information

Assembly Language Instructions

Assembly Language Instructions Assembly Language Instructions Content: Assembly language instructions of PIC16F887. Programming by assembly language. Prepared By- Mohammed Abdul kader Assistant Professor, EEE, IIUC Assembly Language

More information

PIC16F87X 13.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

PIC16F87X 13.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS PIC6F87X 3.0 INSTRUCTION SET SUMMARY Each PIC6F87X instruction is a 4bit word, divided into an OPCODE which specifies the instruction type and one or more operands which further specify the operation of

More information

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27) Lesson 14 Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27) Name and affiliation of the author: N W K Jayatissa Department of Physics,

More information

Section 14. Timer1 HIGHLIGHTS. Timer1. This section of the manual contains the following major topics:

Section 14. Timer1 HIGHLIGHTS. Timer1. This section of the manual contains the following major topics: Section 14. Timer1 HIGHLIGHTS This section of the manual contains the following major topics: 14.1 Introduction... 14-2 14.2 Control Register... 14-4 14.3 Timer1 Operation in Timer Mode... 14-5 14.4 Timer1

More information

University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory

University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory 0907334 6 Experiment 6:Timers Objectives To become familiar with hardware timing

More information

Embedded System Design

Embedded System Design ĐẠI HỌC QUỐC GIA TP.HỒ CHÍ MINH TRƯỜNG ĐẠI HỌC BÁCH KHOA KHOA ĐIỆN-ĐIỆN TỬ BỘ MÔN KỸ THUẬT ĐIỆN TỬ Embedded System Design : Microcontroller 1. Introduction to PIC microcontroller 2. PIC16F84 3. PIC16F877

More information

Outlines. PIC Programming in C and Assembly. Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University

Outlines. PIC Programming in C and Assembly. Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University PIC ming in C and Assembly Outlines Microprocessor vs. MicroController PIC in depth PIC ming Assembly ming Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University Embedded C

More information

PIC16F870/ /40-Pin, 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram. Microcontroller Core Features:

PIC16F870/ /40-Pin, 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram. Microcontroller Core Features: 28/40-Pin, 8-Bit CMOS FLASH Microcontrollers Devices Included in this Data Sheet: Pin Diagram PIC16F870 PIC16F871 PDIP Microcontroller Core Features: High performance RISC CPU Only 35 single word instructions

More information

Embedded systems. Exercise session 3. Microcontroller Programming Lab Preparation

Embedded systems. Exercise session 3. Microcontroller Programming Lab Preparation Embedded systems Exercise session 3 Microcontroller Programming Lab Preparation Communications Contact Mail : michael.fonder@ulg.ac.be Office : 1.82a, Montefiore Website for the exercise sessions and the

More information

NH-67, TRICHY MAIN ROAD, PULIYUR, C.F , KARUR DT. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COURSE MATERIAL

NH-67, TRICHY MAIN ROAD, PULIYUR, C.F , KARUR DT. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COURSE MATERIAL NH-67, TRICHY MAIN ROAD, PULIYUR, C.F. 639 114, KARUR DT. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COURSE MATERIAL Subject Name : Embedded System Class/Sem : BE (ECE) / VII Subject Code

More information

PIC16F818/819 Data Sheet

PIC16F818/819 Data Sheet Data Sheet 18/20-Pin Enhanced FLASH Microcontrollers with nanowatt Technology 2002 Microchip Technology Inc. Preliminary DS39598C Note the following details of the code protection feature on Microchip

More information

Section 11. Timer0. Timer0 HIGHLIGHTS. This section of the manual contains the following major topics:

Section 11. Timer0. Timer0 HIGHLIGHTS. This section of the manual contains the following major topics: M 11 Section 11. HIGHLIGHTS This section of the manual contains the following major topics: 11.1 Introduction...11-2 11.2 Control Register...11-3 11.3 Operation...11-4 11.4 TMR0 Interrupt...11-5 11.5 Using

More information

PIC Microcontroller Embedded Systems Hadassah College Spring 2012 PIC Microcontroller Dr. Martin Land

PIC Microcontroller Embedded Systems Hadassah College Spring 2012 PIC Microcontroller Dr. Martin Land PIC Microcontroller 1 (MCU) Widely used device from Microchip Technology Sold > 10 billion PIC controllers Several device families Many devices per family Common development environment Widely available

More information

Week1. EEE305 Microcontroller Key Points

Week1. EEE305 Microcontroller Key Points Week1 Harvard Architecture Fig. 3.2 Separate Program store and Data (File) stores with separate Data and Address buses. Program store Has a 14-bit Data bus and 13-bit Address bus. Thus up to 2 13 (8K)

More information

Hardware Interfacing. EE25M Introduction to microprocessors. Part V. 15 Interfacing methods. original author: Feisal Mohammed

Hardware Interfacing. EE25M Introduction to microprocessors. Part V. 15 Interfacing methods. original author: Feisal Mohammed EE25M Introduction to microprocessors original author: Feisal Mohammed updated: 18th February 2002 CLR Part V Hardware Interfacing There are several features of computers/microcontrollers which have not

More information

PIC16F /40-Pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features:

PIC16F /40-Pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features: 28/40-Pin 8-Bit CMOS FLASH Microcontrollers Devices Included in this Data Sheet: PIC16F870 PIC16F871 Microcontroller Core Features: High-performance RISC CPU Only 35 single word instructions to learn All

More information

M PIC16F84A. 18-pinEnhanced FLASH/EEPROM 8-Bit Microcontroller. High Performance RISC CPU Features: Pin Diagrams. Peripheral Features:

M PIC16F84A. 18-pinEnhanced FLASH/EEPROM 8-Bit Microcontroller. High Performance RISC CPU Features: Pin Diagrams. Peripheral Features: M PIC6F84A 8-pinEnhanced FLASH/EEPROM 8-Bit Microcontroller High Performance RISC CPU Features: Pin Diagrams Only 35 single word instructions to learn All instructions single-cycle except for program branches

More information

Section 13. Timer0 HIGHLIGHTS. Timer0. This section of the manual contains the following major topics:

Section 13. Timer0 HIGHLIGHTS. Timer0. This section of the manual contains the following major topics: Section 13. Timer0 HIGHLIGHTS This section of the manual contains the following major topics: 13.1 Introduction... 13-2 13.2 Control Register... 13-3 13.3 Operation... 13-4 13.4 Timer0 Interrupt... 13-5

More information

Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar

Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar Starting to Program Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar Outline Introduction Program Development Process The PIC 16F84A Instruction Set Examples The PIC 16F84A Instruction Encoding Assembler Details

More information

PIC16C84. 8-bit CMOS EEPROM Microcontroller PIC16C84. Pin Diagram. High Performance RISC CPU Features: CMOS Technology: Peripheral Features:

PIC16C84. 8-bit CMOS EEPROM Microcontroller PIC16C84. Pin Diagram. High Performance RISC CPU Features: CMOS Technology: Peripheral Features: 8-bit CMOS EEPROM Microcontroller High Performance RISC CPU Features: Only 35 single word instructions to learn All instructions single cycle (400 ns @ 10 MHz) except for program branches which are two-cycle

More information

PIC16F87X. 28/40-pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features:

PIC16F87X. 28/40-pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features: 28/40-pin 8-Bit CMOS FLASH Microcontrollers Devices Included in this Data Sheet: PIC16F873 PIC16F874 PIC16F876 PIC16F877 Microcontroller Core Features: High-performance RISC CPU Only 35 single word instructions

More information

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006 CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT Spring 2006 Recitation 01 21.02.2006 CEng336 1 OUTLINE LAB & Recitation Program PIC Architecture Overview PIC Instruction Set PIC Assembly Code Structure 21.02.2006

More information

Embedded Systems Design (630470) Lecture 4. Memory Organization. Prof. Kasim M. Al-Aubidy Computer Eng. Dept.

Embedded Systems Design (630470) Lecture 4. Memory Organization. Prof. Kasim M. Al-Aubidy Computer Eng. Dept. Embedded Systems Design (630470) Lecture 4 Memory Organization Prof. Kasim M. Al-Aubidy Computer Eng. Dept. Memory Organization: PIC16F84 has two separate memory blocks, for data and for program. EEPROM

More information

SPI Serial SRAM: Recommended Usage

SPI Serial SRAM: Recommended Usage SPI Serial SRAM: Recommended Usage Serial SRAM Advantages Hardware Recommendations Status Register 009 Microchip Technology Incorporated. All Rights Reserved. SPI EEPROM Usage Slide Hi, my name is Barry

More information

SOLUTIONS!! DO NOT DISTRIBUTE!!

SOLUTIONS!! DO NOT DISTRIBUTE!! THE UNIVERSITY OF THE WEST INDIES EXAMINATIONS OF FEBRUARY MID-TERM 2005 Code and Name of Course: EE25M Introduction to Microprocessors Paper: Date and Time: Duration: One Hour INSTRUCTIONS TO CANDIDATES:

More information

Laboratory Exercise 5 - Analog to Digital Conversion

Laboratory Exercise 5 - Analog to Digital Conversion Laboratory Exercise 5 - Analog to Digital Conversion The purpose of this lab is to control the blinking speed of an LED through the Analog to Digital Conversion (ADC) module on PIC16 by varying the input

More information

PIC16F872 Data Sheet. 28-Pin, 8-Bit CMOS Flash Microcontroller with 10-Bit A/D Microchip Technology Inc. DS30221C

PIC16F872 Data Sheet. 28-Pin, 8-Bit CMOS Flash Microcontroller with 10-Bit A/D Microchip Technology Inc. DS30221C Data Sheet 28-Pin, 8-Bit CMOS Flash Microcontroller with 10-Bit A/D 2006 Microchip Technology Inc. DS30221C Note the following details of the code protection feature on Microchip devices: Microchip products

More information

Contents. PIC Mini Data Sheets

Contents. PIC Mini Data Sheets Contents PIC16C5x... 5 PIC16C5x Pin-Outs... 5 PIC16C5x Microcontrollers... 6 Peripheral Features... 6 Internal Architecture... 9 PIC16C5x Registers... 9 PIC16C64... 18 PIC16C64 Pin-Out...18 New and Modified

More information

which means that writing to a port implies that the port pins are first read, then this value is modified and then written to the port data latch.

which means that writing to a port implies that the port pins are first read, then this value is modified and then written to the port data latch. Introduction to microprocessors Feisal Mohammed 3rd January 2001 Additional features 1 Input/Output Ports One of the features that differentiates a microcontroller from a microprocessor is the presence

More information

DERTS Design Requirements (1): Microcontroller Architecture & Programming

DERTS Design Requirements (1): Microcontroller Architecture & Programming Lecture (5) DERTS Design Requirements (1): Microcontroller Architecture & Programming Prof. Kasim M. Al-Aubidy Philadelphia University 1 Lecture Outline: Features of microcomputers and microcontrollers.

More information

Welcome to Installing and using HI-TECH C PRO for the PIC10/12/16 MCU Family with the MPLAB IDE.

Welcome to Installing and using HI-TECH C PRO for the PIC10/12/16 MCU Family with the MPLAB IDE. Installing and using HI-TECH C PRO for the PIC10/12/16 MCU Family with the MPLAB IDE 1 Welcome to Installing and using HI-TECH C PRO for the PIC10/12/16 MCU Family with the MPLAB IDE. This webinar will

More information

PIC16F8X 18-pin Flash/EEPROM 8-Bit Microcontrollers

PIC16F8X 18-pin Flash/EEPROM 8-Bit Microcontrollers 18-pin Flash/EEPROM 8-Bit Microcontrollers Devices Included in this Data Sheet: PIC16F83 PIC16F84 PIC16CR83 PIC16CR84 Extended voltage range devices available (PIC16LF8X, PIC16LCR8X) High Performance RISC

More information

Section 4. Architecture

Section 4. Architecture M Section 4. Architecture HIGHLIGHTS This section of the manual contains the following major topics: 4. Introduction...4-2 4.2 Clocking Scheme/Instruction Cycle...4-5 4.3 Instruction Flow/Pipelining...4-6

More information

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE6008 Microcontroller based system design

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE6008 Microcontroller based system design Year: IV DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING EE6008 Microcontroller based system design Semester : VII UNIT I Introduction to PIC Microcontroller

More information

CENG-336 Introduction to Embedded Systems Development. Timers

CENG-336 Introduction to Embedded Systems Development. Timers CENG-336 Introduction to Embedded Systems Development Timers Definitions A counter counts (possibly asynchronous) input pulses from an external signal A timer counts pulses of a fixed, known frequency

More information

PIC16F87XA Data Sheet

PIC16F87XA Data Sheet M Data Sheet 28/40-pin Enhanced FLASH Microcontrollers 2001 Microchip Technology Inc. Advance Information DS39582A 2001 Microchip Technology Inc. Advance Information DS39582A-page 3 Pin Diagram RB7/PGD

More information

TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE. E4160 Microprocessor & Microcontroller System. Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010

TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE. E4160 Microprocessor & Microcontroller System. Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010 TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010 E4160 Microprocessor & Microcontroller System Learning Outcomes 2 At the end of this topic, students should

More information

PIC16F8X. 8-Bit CMOS Flash/EEPROM Microcontrollers PIC16F8X PIC16CR8X. Pin Diagram. Devices Included in this Data Sheet:

PIC16F8X. 8-Bit CMOS Flash/EEPROM Microcontrollers PIC16F8X PIC16CR8X. Pin Diagram. Devices Included in this Data Sheet: This document was created with FrameMaker 404 PIC16F8X 8-Bit CMOS Flash/EEPROM Microcontrollers Devices Included in this Data Sheet: PIC16F83 PIC16CR83 PIC16F84 PIC16CR84 Extended voltage range devices

More information

PIC12F629/675 Data Sheet

PIC12F629/675 Data Sheet M PIC12F62/675 Data Sheet 8-Pin FLASH-Based 8-Bit CMOS Microcontrollers 2002 Microchip Technology Inc. Preliminary DS4110A Note the following details of the code protection feature on PICmicro MCUs. The

More information

Learning Objectives:

Learning Objectives: Topic 5.2.1 PIC microcontrollers Learning Objectives: At the end of this topic you will be able to; Recall the architecture of a PIC microcontroller, consisting of CPU, clock, data memory, program memory

More information

PIC16C63A/65B/73B/74B

PIC16C63A/65B/73B/74B PI663A/65B/73B/74B 4.0 MEMORY ORGANIATION 4. Program Memory Organization The PI663A/65B/73B/74B has a 3bit program counter capable of addressing an 8K x 4 program memory space. All devices covered by this

More information

ME 6405 Introduction to Mechatronics

ME 6405 Introduction to Mechatronics ME 6405 Introduction to Mechatronics Fall 2006 Instructor: Professor Charles Ume Microchip PIC Manufacturer Information: Company: Website: http://www.microchip.com Reasons for success: Became the hobbyist's

More information

Mod-5: PIC 18 Introduction 1. Module 5

Mod-5: PIC 18 Introduction 1. Module 5 Mod-5: PIC 18 Introduction 1 Module 5 Contents: Overview of PIC 18, memory organisation, CPU, registers, pipelining, instruction format, addressing modes, instruction set, interrupts, interrupt operation,

More information

Embedded Systems Programming and Architectures

Embedded Systems Programming and Architectures Embedded Systems Programming and Architectures Lecture No 10 : Data acquisition and data transfer Dr John Kalomiros Assis. Professor Department of Post Graduate studies in Communications and Informatics

More information

PIC16F7X Data Sheet. 28/40-pin, 8-bit CMOS FLASH Microcontrollers Microchip Technology Inc. DS30325B

PIC16F7X Data Sheet. 28/40-pin, 8-bit CMOS FLASH Microcontrollers Microchip Technology Inc. DS30325B M PIC16F7X Data Sheet 28/40-pin, 8-bit CMOS FLASH Microcontrollers 2002 Microchip Technology Inc. DS30325B Note the following details of the code protection feature on PICmicro MCUs. The PICmicro family

More information

PIC16C62X Data Sheet. EPROM-Based 8-Bit CMOS Microcontrollers Microchip Technology Inc. DS30235J

PIC16C62X Data Sheet. EPROM-Based 8-Bit CMOS Microcontrollers Microchip Technology Inc. DS30235J Data Sheet EPROM-Based 8-Bit CMOS Microcontrollers 2003 Microchip Technology Inc. DS30235J Note the following details of the code protection feature on Microchip devices: Microchip products meet the specification

More information

PIC16C432 OTP 8-Bit CMOS MCU with LIN bus Transceiver

PIC16C432 OTP 8-Bit CMOS MCU with LIN bus Transceiver OTP 8-Bit CMOS MCU with LIN bus Transceiver Devices included in this Data Sheet: High Performance RISC CPU: Only 35 instructions to learn All single cycle instructions (200 ns), except for program branches

More information

PIC16F84A. 18-pin Enhanced Flash/EEPROM 8-Bit Microcontroller. Devices Included in this Data Sheet: Pin Diagrams. High Performance RISC CPU Features:

PIC16F84A. 18-pin Enhanced Flash/EEPROM 8-Bit Microcontroller. Devices Included in this Data Sheet: Pin Diagrams. High Performance RISC CPU Features: M PIC6F84A 8-pin Enhanced Flash/EEPROM 8-Bit Microcontroller Devices Included in this Data Sheet: PIC6F84A Extended voltage range device available (PIC6LF84A) High Performance RISC CPU Features: Only 35

More information

LAB WORK 2. 1) Debugger-Select Tool-MPLAB SIM View-Program Memory Trace the program by F7 button. Lab Work

LAB WORK 2. 1) Debugger-Select Tool-MPLAB SIM View-Program Memory Trace the program by F7 button. Lab Work LAB WORK 1 We are studying with PIC16F84A Microcontroller. We are responsible for writing assembly codes for the microcontroller. For the code, we are using MPLAB IDE software. After opening the software,

More information

PIC16F630/676 Data Sheet

PIC16F630/676 Data Sheet M PIC16F630/676 Data Sheet 14-Pin FLASH-Based 8-Bit CMOS Microcontrollers 2002 Microchip Technology Inc. Preliminary DS4003A Note the following details of the code protection feature on PICmicro MCUs.

More information

Speed Control of a DC Motor using Digital Control

Speed Control of a DC Motor using Digital Control Speed Control of a DC Motor using Digital Control The scope of this project is threefold. The first part of the project is to control an LCD display and use it as part of a digital tachometer. Secondly,

More information

Embedded Systems. PIC16F84A Internal Architecture. Eng. Anis Nazer First Semester

Embedded Systems. PIC16F84A Internal Architecture. Eng. Anis Nazer First Semester Embedded Systems PIC16F84A Internal Architecture Eng. Anis Nazer First Semester 2017-2018 Review Computer system basic components? CPU? Memory? I/O? buses? Instruction? Program? Instruction set? CISC,

More information

Distributed by: www.jameco.com 1-800-831-4242 The content and copyrights of the attached material are the property of its owner. M PIC16F87XA Data Sheet 28/40-pin Enhanced FLASH Microcontrollers 2001 Microchip

More information

EEE394 Microprocessor and Microcontroller Laboratory Lab #6

EEE394 Microprocessor and Microcontroller Laboratory Lab #6 Exp. No #6 Date: INTERRUPTS AND ADC IN PIC MICROCONTROLLER OBJECTIVE The purpose of the experiment is to configure external interrupt and the ADC in PIC microcontrollers. (i) To flip the LED connected

More information

PIC16F630/676 Data Sheet

PIC16F630/676 Data Sheet Data Sheet 14-Pin, Flash-Based 8-Bit CMOS Microcontrollers 2007 Microchip Technology Inc. DS40039E Note the following details of the code protection feature on Microchip devices: Microchip products meet

More information

PIC16F87/88 Data Sheet

PIC16F87/88 Data Sheet Data Sheet 18/20/28-Pin Enhanced Flash Microcontrollers with nanowatt Technology 2005 Microchip Technology Inc. DS30487C Note the following details of the code protection feature on Microchip devices:

More information

PIC16F5X Data Sheet. Flash-Based, 8-Bit CMOS Microcontroller Series Microchip Technology Inc. DS41213D

PIC16F5X Data Sheet. Flash-Based, 8-Bit CMOS Microcontroller Series Microchip Technology Inc. DS41213D Data Sheet Flash-Based, 8-Bit CMOS Microcontroller Series 2007 Microchip Technology Inc. DS41213D Note the following details of the code protection feature on Microchip devices: Microchip products meet

More information

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017 Philadelphia University Faculty of Engineering Course Title: Embedded Systems (630414) Instructor: Eng. Anis Nazer Dept. of Computer Engineering Final Exam, First Semester: 2016/2017 Student Name: Student

More information

Embedded Systems. PIC16F84A Sample Programs. Eng. Anis Nazer First Semester

Embedded Systems. PIC16F84A Sample Programs. Eng. Anis Nazer First Semester Embedded Systems PIC16F84A Sample Programs Eng. Anis Nazer First Semester 2017-2018 Development cycle (1) Write code (2) Assemble / compile (3) Simulate (4) Download to MCU (5) Test Inputs / Outputs PIC16F84A

More information

PIC16F5X Data Sheet. Flash-Based, 8-Bit CMOS Microcontroller Series

PIC16F5X Data Sheet. Flash-Based, 8-Bit CMOS Microcontroller Series Data Sheet Flash-Based, 8-Bit CMOS Microcontroller Series Note the following details of the code protection feature on Microchip devices: Microchip products meet the specification contained in their particular

More information

Outline. Micriprocessor vs Microcontroller Introduction to PIC MCU PIC16F877 Hardware:

Outline. Micriprocessor vs Microcontroller Introduction to PIC MCU PIC16F877 Hardware: HCMIU - DEE Subject: ERTS RISC MCU Architecture PIC16F877 Hardware 1 Outline Micriprocessor vs Microcontroller Introduction to PIC MCU PIC16F877 Hardware: Program Memory Data memory organization: banks,

More information

Sales: Technical: Fax:

Sales: Technical: Fax: DATA SHEET PIC Microcontrollers Order code Manufacturer code Description 73-3352 n/a PIC16F877A-I/P (RC) PIC Microcontrollers The enclosed information is believed to be correct, Information may change

More information

PIC16F84A 7.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

PIC16F84A 7.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS PI6F84A 7.0 INSTRUTION SET SUMMARY Each PI6XX instruction is a 4bit word, divided into an OPODE which specifies the instruction type and one or more operands which further specify the operation of the

More information

PIC16C7X 11.0 SYNCHRONOUS SERIAL PORT (SSP) MODULE SSP Module Overview. Applicable Devices

PIC16C7X 11.0 SYNCHRONOUS SERIAL PORT (SSP) MODULE SSP Module Overview. Applicable Devices Applicable Devices PIC16C7X 11.0 SYNCHRONOUS SERIAL PORT (SSP) MODULE 11.1 SSP Module Overview The Synchronous Serial Port (SSP) module is a serial interface useful for communicating with other peripheral

More information

PIC Microcontroller. PIC Microcontroller (MCU) Typical Applications. PIC Families

PIC Microcontroller. PIC Microcontroller (MCU) Typical Applications. PIC Families (MCU) PIC Microcontroller Widely used device from Microchip Technology Sold > billion PIC controllers Several device families Many devices per family Common development environment Widely available Large

More information

Chapter 13. PIC Family Microcontroller

Chapter 13. PIC Family Microcontroller Chapter 13 PIC Family Microcontroller Lesson 06 Special Function Registers for Control and status registers for the peripherals, input/output and Interrupt SFRs SFRs at the addresses of internal RAM/register

More information

PIC16F627A/628A/648A. PIC16F627A/628A/648A Rev. A Silicon/Data Sheet Errata. 2. Module: EC Clock. 1. Module: Programming Operations

PIC16F627A/628A/648A. PIC16F627A/628A/648A Rev. A Silicon/Data Sheet Errata. 2. Module: EC Clock. 1. Module: Programming Operations PIC16F627A/628A/648A Rev. A Silicon/Data Sheet Errata The PIC16F627A/628A/648A parts you have received conform functionally to the Device Data Sheet (DS40044E), except for the anomalies described below.

More information

PIC16F5X Data Sheet. Flash-Based, 8-Bit CMOS Microcontrollers Microchip Technology Inc. Preliminary DS41213B

PIC16F5X Data Sheet. Flash-Based, 8-Bit CMOS Microcontrollers Microchip Technology Inc. Preliminary DS41213B Data Sheet Flash-Based, 8-Bit CMOS Microcontrollers 2004 Microchip Technology Inc. Preliminary DS41213B Note the following details of the code protection feature on Microchip devices: Microchip products

More information

PIC Microcontroller Introduction

PIC Microcontroller Introduction PIC Microcontroller Introduction The real name of this microcontroller is PICmicro (Peripheral Interface Controller), but it is better known as PIC. Its first ancestor was designed in 1975 by General Instruments.

More information

R&E International A Subsidiary of Microchip Technology Inc.

R&E International A Subsidiary of Microchip Technology Inc. RE46C104 General Description The RE46C104 is a piezoelectric horn driver with voltage converter to provide maximum audibility in low voltage applications. The feedback control pin is designed for use with

More information

PIC Discussion. By Eng. Tamar Jomaa

PIC Discussion. By Eng. Tamar Jomaa PIC Discussion By Eng. Tamar Jomaa Chapter#2 Programming Microcontroller Using Assembly Language Quiz#1 : Time: 10 minutes Marks: 10 Fill in spaces: 1) PIC is abbreviation for 2) Microcontroller with..architecture

More information

Microcontroller Overview

Microcontroller Overview Microcontroller Overview Microprocessors/Microcontrollers/DSP Microcontroller components Bus Memory CPU Peripherals Programming Microcontrollers vs. µproc. and DSP Microprocessors High-speed information

More information

Laboratory 9. Programming a PIC Microcontroller - Part I

Laboratory 9. Programming a PIC Microcontroller - Part I Laboratory 9 Programming a PIC Microcontroller - Part I Required Components: 1 PIC16F84 (4MHz) or PIC16F84A (20MHz) or compatible (e.g., PIC16F88) microcontroller 1 4MHz microprocessor crystal (20 pf),

More information

PIC16C745/ Bit CMOS Microcontrollers with USB. Pin Diagrams. Devices included in this data sheet: Microcontroller Core Features:

PIC16C745/ Bit CMOS Microcontrollers with USB. Pin Diagrams. Devices included in this data sheet: Microcontroller Core Features: 8-Bit CMOS Microcontrollers with USB Devices included in this data sheet: PIC16C745 PIC16C765 Microcontroller Core Features: High-performance RISC CPU Only 35 single word instructions Device Memory Program

More information

Flow Charts and Assembler Programs

Flow Charts and Assembler Programs Flow Charts and Assembler Programs Flow Charts: A flow chart is a graphical way to display how a program works (i.e. the algorithm). The purpose of a flow chart is to make the program easier to understand.

More information

These 3 registers contain enable, priority,

These 3 registers contain enable, priority, 8.3.2) Registers Related to Interrupts These registers enable/disable the interrupts, set the priority of the interrupts, and record the status of each interrupt source. RCON INTCON, INTCON2, and INTCON3

More information

movwf prevcod ; a new button is pressed - rcnt=3 movwf (mtx_buffer+1) movlw 3 movwf rcnt

movwf prevcod ; a new button is pressed - rcnt=3 movwf (mtx_buffer+1) movlw 3 movwf rcnt movlw 0x20 #endif call scan movlw 0xfd tris PORTB ; select colb (RB1) #ifdef MODE_CH8 movlw 0x04 #endif #ifdef MODE_CH4 movlw 0x30 #endif call scan movf cod, W bz loop2 ; if no buton is pressed, skip subwf

More information

Fortune. Semiconductor Corporation 富晶半導體股份有限公司. 8-bit MCU with 1k program ROM, 64-byte RAM, 1 R2F module and 3 13 LCD driver. TD Rev. 1.

Fortune. Semiconductor Corporation 富晶半導體股份有限公司. 8-bit MCU with 1k program ROM, 64-byte RAM, 1 R2F module and 3 13 LCD driver. TD Rev. 1. Fortune 1 R2F module and 3 13 LCD driver. Data Sheet TD-0410001 Rev. 1.2 This manual contains new product information. Fortune reserves the rights to modify the product specification without further notice.

More information

PIC16F8X PIC16F8X. 18-pin Flash/EEPROM 8-Bit Microcontrollers

PIC16F8X PIC16F8X. 18-pin Flash/EEPROM 8-Bit Microcontrollers Devices Included in this Data Sheet: PIC6F83 PIC6F84 PIC6CR83 PIC6CR84 Extended voltage range devices available (PIC6LF8X, PIC6LCR8X) High Performance RISC CPU Features: Only 35 single word instrucs to

More information

Table of Contents COMPANY PROFILE 1-1 SECTION 1. INTRODUCTION 1-1

Table of Contents COMPANY PROFILE 1-1 SECTION 1. INTRODUCTION 1-1 COMPANY PROFILE 1-1 SECTION 1. INTRODUCTION 1-1 Introduction... 1-2 Manual Objective... 1-3 Device Structure... 1-4 Development Support... 1-6 Device Varieties... 1-7 Style and Symbol Conventions... 1-12

More information

AN587. Interfacing to an LCD Module. Interfacing to an LCD Module INTRODUCTION OPERATION CONTROL SIGNAL FUNCTIONS TABLE 2: CONDITIONAL ASSEMBLY FLAGS

AN587. Interfacing to an LCD Module. Interfacing to an LCD Module INTRODUCTION OPERATION CONTROL SIGNAL FUNCTIONS TABLE 2: CONDITIONAL ASSEMBLY FLAGS Interfacing to an LCD Module AN587 INTRODUCTION TABLE 1: CONTROL SIGNAL FUNCTIONS This application note interfaces a PIC16CXX device to the Hitachi LM02L LCD character display module. This module is a

More information

TB082. Understanding Reset Events On The PIC10F20X INTRODUCTION WATCHDOG TIMER OR WDT POWER-ON RESET (POR)

TB082. Understanding Reset Events On The PIC10F20X INTRODUCTION WATCHDOG TIMER OR WDT POWER-ON RESET (POR) Understanding Reset Events On The PIC10F20X Author: INTRODUCTION The PIC10F20X family of microcontrollers utilizes the baseline 12-bit microcontroller core from Microchip. Because this core does not support

More information

Chapter 10 Sections 1,2,9,10 Dr. Iyad Jafar

Chapter 10 Sections 1,2,9,10 Dr. Iyad Jafar Starting with Serial Chapter 10 Sections 1,2,9,10 Dr. Iyad Jafar Outline Introduction Synchronous Serial Communication Asynchronous Serial Communication Physical Limitations Overview of PIC 16 Series The

More information

Section 16. Basic Sychronous Serial Port (BSSP)

Section 16. Basic Sychronous Serial Port (BSSP) M 16 Section 16. Basic Sychronous Serial Port (BSSP) BSSP HIGHLIGHTS This section of the manual contains the following major topics: 16.1 Introduction...16-2 16.2 Control Registers...16-3 16.3 SPI Mode...16-6

More information

Timer2 Interrupts. NDSU Timer2 Interrupts September 20, Background:

Timer2 Interrupts. NDSU Timer2 Interrupts September 20, Background: Background: Timer2 Interrupts The execution time for routines sometimes needs to be set. This chapter loops at several ways to set the sampling rate. Example: Write a routine which increments an 8-bit

More information

Timer1 Capture Mode:

Timer1 Capture Mode: Timer1 Capture Mode: Interrupt Description Input Conditions Enable Flag Timer 1 Trigger after N events N = 1.. 2 19 100ns to 0.52 sec RC0 TMR1CS = 1 TMR1IF Timer 1 Capture Mode 1 Timer 1 Capture Mode 2

More information

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application... Overview of the PIC 16F648A Processor: Part 1 EE 361L Lab 2.1 Last update: August 19, 2011 Abstract: This report is the first of a three part series that discusses the features of the PIC 16F684A processor,

More information

Micro II and Embedded Systems

Micro II and Embedded Systems 16.480/552 Micro II and Embedded Systems Introduction to PIC Microcontroller Revised based on slides from WPI ECE2801 Moving Towards Embedded Hardware Typical components of a PC: x86 family microprocessor

More information

MPLAB SIM. MPLAB IDE Software Simulation Engine Microchip Technology Incorporated MPLAB SIM Software Simulation Engine

MPLAB SIM. MPLAB IDE Software Simulation Engine Microchip Technology Incorporated MPLAB SIM Software Simulation Engine MPLAB SIM MPLAB IDE Software Simulation Engine 2004 Microchip Technology Incorporated MPLAB SIM Software Simulation Engine Slide 1 Welcome to this web seminar on MPLAB SIM, the software simulator that

More information

Input/Output Ports and Interfacing

Input/Output Ports and Interfacing Input/Output Ports and Interfacing ELEC 330 Digital Systems Engineering Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning Basic I/O Concepts Peripherals such as LEDs and keypads are essential

More information

Timer0..Timer3. Interrupt Description Input Conditions Enable Flag

Timer0..Timer3. Interrupt Description Input Conditions Enable Flag Timer0..Timer3 Timers are pretty useful: likewise, Microchip provides four different timers for you to use. Like all interrupts, you have to Enable the interrupt, Set the conditions of the interrupt, and

More information

Chapter 13. PIC Family Microcontroller

Chapter 13. PIC Family Microcontroller Chapter 13 PIC Family Microcontroller Lesson 15 Instruction Set Most instructions execution Time One instruction cycle If XTAL frequency = 20 MHz, then instruction cycle time is 0.2 s or 200 ns (= 4/20

More information

DRPIC166X IP Core. High Performance 8-bit RISC Microcontroller v. 2.17

DRPIC166X IP Core. High Performance 8-bit RISC Microcontroller v. 2.17 2017 DRPIC166X IP Core High Performance 8-bit RISC Microcontroller v. 2.17 C O M P A N Y O V E R V I E W Digital Core Design is a leading IP Core provider and a System-on-Chip design house. The company

More information