
-
Tutorial (9): Creating arrays using indirect addressing in PIC microcontrollers
Techno GateAddressing the INDF register will cause indirect addressing. Indirect addressing is possible by using the INDF register. Any instruction using the INDF register actually accesses the register pointed to by the File Select Register (FSR). Reading the INDF register itself, indirectly (FSR = 0) will read 00h. Writing to the INDF register indirectly results in a no operation. An effective 9-bit address is obtained by concatenating the 8-bit FSR register and the IRP bit . Indirect addressing can be used to handle several registers without referring to them directly.128 views 1 comment -
Tutorial (8): Creating arrays using lookup tables in PIC microcontrollers
Techno GateA look-up table is a block of data that is held in the program memory and which can be accessed by the program and used within it. The table is formed as a subroutine. Every byte of data in the table is accompanied by a special instruction retlw. As it implements the subroutine return, it picks up its operand and puts it into the W register. We use something called ‘computed go to’ using the instruction addwf pcl. The contents of the W register are added to pcl, which is the lower byte of the program counter. Once a number has been added to the program counter, program execution jumps forward by whatever that number was127 views -
Tutorial (7): Creating Software Delay and Hardware Delay in PIC Microcontrollers
Techno GateIn this tutorial, I will show you how to calculate the variables defined in the software delay and hardware delay. I also write the assembly code of the software delay and hardware delay based on these calculations131 views 1 comment -
Experiment (4): Interrupts in PIC microcontroller
Techno Gate* Create MPLAB project, use steps. * Four LED is connected to PORTC (RC0:RC3) using PIC 16F877A. * Enable external interrupt and connected RB0 to push button. * Use the MPLAB to write an assembly program that light the of LED’s when interrupt occurs.82 views -
Experiment (3): Creating software delay in PIC microcontroller
Techno Gate* Create MPLAB project. * One LED is connected to PORTC (RC0,RC1) using PIC 16F877A. * For 4MHz clock frequency and 1sec software delay, define the instructions of the recursive loop and calculate the values of the variables (if needed) * Use the MPLAB to write an assembly program that flash light the of LED ON/OFF for a delay of 1sec.82 views -
Tutorial (6): Branching and Conditional Instructions in PIC Microcontrollers
Techno Gate* One of the most important features of any microprocessor or microcontroller program is its ability to make ‘decisions’. * Microprocessors generally have within their instruction sets a number of instructions which allow them to test a particular bit, and either continue program execution if a condition is not met or branch to another part of the program if it is. 1) Tests bit b in memory location f and skips just one instruction if the bit is clear. BTFSC f,b: Bit Test f, Skip if Clear 2) Tests bit b in memory location f and skips just one instruction if the bit is set. BTFSS f,b : Bit Test f, Skip if Set 3) DECFSZ f,d: Decrement f, Skip if 0 4) INCFSZ f,d: Increment f, Skip if 080 views -
Tutorial (5): Logical Instructions in PIC microcontrollers
Techno GateIn this tutorial, we presents: - ANDLW k: AND literal with w (w = k.w) - ANDWF f,d : AND w with f (w= w.f) or (f= w.f) - IORLW k: Inclusive OR literal with w (w= k+w) - IORWF f,d: Inclusive OR w with f (w= w+f) or (f=w+f) - XORLW k: Exclusive OR literal with w - XORWF f,d: Exclusive OR w with f - COMF f,d: Complement f72 views -
Tutorial (4): Arithmetic Instructions in PIC microcontrollers
Techno GateThe tutorial presents the following: - ADDLW k : adds literal and w (w = w+k) - ADDWF f,d: adds w and f (w= w+f) or (f= w+f) - INCF f : increment f (f=f+1) - SUBLW k: subtracts w from literal (w= k-w) - SUBWF f,d: subtracts w from f (w=f-w) or (f=f-w) - DECF f: decrement f (f=f-1) Status register bits Zero, Carry and Digit Carry respond to certain arithmetic instructions. The Subtract instructions follow a similar pattern to the Add The Carry bit now, however, acts as a Borrow. If a subtract occurs and the result is positive, then the Carry bit is ‘set’. If the result is negative, then the Carry bit is ‘clear’ Define two constant and apply the arithmetic operations between them.80 views 1 comment -
Tutorial (3): PIC input/Output Ports with Addition
Techno GateThe tutorial presents the following exercises: 1) Four LEDs are connected to PORTB (RB3:RB0) using PIC 16F84A. Use the MPLAB to write an assembly program that light the LEDs. 2) Write a program that repeatedly adds a number to the W register 3) Write a program that repeatedly adds a number to w register and send it to port B. 4) Two switches are connected to PORTA (RA4:RA3) and LEDs are connected to PORTB. Write a program that moves push button switch values from Port A to the LEDs in PORTB.56 views 2 comments -
Tutorial (2) Using Output ports in PIC microcontrollers
Techno GateIn this tutorial, we demonstrate the following: 1. Use PIC port as an output 2. Define the port direction using TRIS registers 3. Use the directives: include, org, banksel and end 4. use the instructions: clrf, movlw, movwf and goto.70 views