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

Size: px
Start display at page:

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

Transcription

1 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, we need to do some configurations. - Project-Project Wizard-Next-Choose Device(PIC16F84A)-Next-Next-Select a destination for your.mcp file-next-finish - File-New--> the file that we will write the code. We need to save this file as.asm file. - After saving the file, we need to add this.asm file under the Source Files - Click build all to check there is a mistake in your code or not. These are the steps to run the code that we have written. 1) The following code is needed to be run. list p=16f84a include p16f84a.inc clrf PORTB; PORTB= , PORTB is an output bsf STATUS, RP0; Change to Bank 1 clrf TRISB; TRISB= bcf STATUS, RP0; Change to Bank 0 bsf PORTB, 0; Make the zeroth bit of PORTB 1 2) We need to open Program Memory Map in MPLAB. For that, - Debugger-Select Tool-MPLAB SIM - View-Program Memory By these steps above, we can trace the program by pressing F7. 3) In the.hex files, 0186 CLRF 0x6 is written instead of clrf PORTB Every command has its own 14-bit instruction word is 14bit instruction word of clrf PORTB command. The address of the PORTB is 06h, and on Assembly Language Instruction Set, across the clrf command fff ffff is written. For the f we need to write address of PORTB, because by clrf PORTB command we want to clear PORTB s content. In the other words, means clear PORTB. The value of this 14-bit number in hexadecimal form is In bsf STATUS RP0 command s 14-bit instruction word is On the table, across bsf command 01 01bb bfff ffff is written. Instead of b we need to write bit number of RP0 which is the fifth bit of the STATUS register, because we want to make this bit 1. Instead of f we need to write the STATUS register s address because we want to change the bit of STATUS Register. For b s we need to write 101 which is 5 in decimal, for f s which is address of the STATUS Register (03 in hexadecimal form). To conclude, means, make the fifth bit(rp0) of STATUS Register. While we are writing 14-bit instruction word, we need to check which bank we are work at.

2 LAB WORK 2 1) We need to determine the errors for the following code: config _cp_off&_wdt_off&_xt_osc clrf portb; PORTB is needed to be written in capitals, this is the error for this question. 2) We need to determine the errors for the following code: clrf PORT; bsf STATUS, RPO; clrf TRISB; In clrf PORT line, there is not any indication whether PORTA or PORTB is used. There is not any register called PORT In bsf STATUS, RPO line, there is not any bit named RPO (letter o), there is RP0(zero). These are the errors for the second question. 3) clrf PORTB; PORTB is CLEARED bsf STATUS, RP0; Change to Bank 1 clrf TRISB; TRISB is cleared bcf STATUS, RP0; Change to Bank0 movlw 0xFF; Move literal(h FF ) to Working Register(W), W=h FF movwf 0x0C; Move the contents of the W into file at the address 0Ch, 0Ch=W=h FF movlw.64; Move literal (decimal 64) to W, W=.64 movwf 0x0D; Move the contents of the W into file at the address 0Dh, 0Dh=W=d 64 movlw b; Move literal (binary ) to W, W=b movwf PORTB; Move the contents of W into PORTB, PORTB=W=b Lab Work 1) Debugger-Select Tool-MPLAB SIM View-Program Memory Trace the program by F7 button Address 06h 03h 86h 83h 0Ch 0Dh 06h Content 0x00 We are only interested in fifth bit of STATUS Register, xx1x xxxx 0x00 We are only interested in fifth bit of STATUS Register, xx0x xxxx 0xFF 0x40 0xF0

3 2) View-Special Function Registers Observe the changes. 3) MOVLW b MOVWF PORTA CLRF PORTB MOVF PORTA,0 MOVWF PORTB LAB WORK 3 1) Command cycle: is referred to a certain amount of time for the CPU to execute an instruction. In PIC16F84A, 1 instruction cycle takes 4 oscillator periods. For 4 MHz oscillator, command cycle=4x(1/4mhz) = 1us For 16 MHz oscillator, command cycle=4x(1/16mhz) =0.25us For 32 MHz oscillator, command cycle=4x(1/32mhz) =0.125us 32 MHz oscillator is the fastest compared to 4MHz and 16Mhz. 2) The following code is needed to be written in MPLAB SIM: clrf PORTB; bsf STATUS, RP0; clrf TRISB; bcf STATUS, RP0; bsf PORTB,0; bcf PORTB,0; After building the code, we want to observe the changes in bit RB0 Debugger-Select Tool-MPLAB SIM View-Logic Analyzer For observing RB0, Channel-RB0-Add-OK Press the play button and trace the program by F7 After bsf PORTB, 0 command, RB0 should be 1 through 5 cycles, until bcf PORTB, 0 command.

4 3) The following code will be built and Logic Analyzer should be opened. We are observing RB0. clrf PORTB; bsf STATUS, RP0; clrf TRISB; bcf STATUS, RP0; bsf PORTB,0; bcf PORTB,0; nop bsf PORTB,0; nop bcf PORTB,0; RB0 is 1(high) through 3 cycles then it is low through 4 cycles and again high through 2 cycles and low for through 1 cycle. 4) The command that take 2cycles: - GOTO - CALL - RETURN - RETLW - RETFIE - INCFSZ; if number of register is 0 take 2 instruction cycle, else take 1 instruction cycle. - DECFSZ; if number of register is 0 take 2 instruction cycle, else take 1 instruction cycle. - BTFSC; if tested bit equal 0 take 2 instruction cycle, else take 1 instruction cycle. - BTFSS; if tested bit equal 1 take 2 instruction cycle, else take 1 instruction cycle. 5) Counter equ 0x0C; free RAM location 12, counter is a register at the address of 0Ch N equ 0x0A; decimal constant 10, N is a variable with the value decimal 10 clrf PORTB; PORTB is cleared bsf STATUS, RP0; Change to Bank1, Make the fifth bit of status Register 1 clrf TRISB; TRISB is cleared bcf STATUS, RP0; Change to Bank0 movlw N; Move literal(n=0x0a) to W, W=N=.10 movwf Counter; Move the content of W into Counter, Counter=W=0x0A bsf PORTB,0; Make the zeroth bit of PORTB(RB0) 1 LOOP decfsz Counter, F; Decrement Counter skip if zero, write decremented value into Counter goto LOOP; This loop will continue until Counter=0 bcf PORTB,0; Make RB0=0

5 Lab Work Calculating the number of cycles needed for 100us delay by using: a) 100KHz oscillator Internal Frequency = 100KHz/4 = 25KHz ICT = 4 x (1/Oscillator Freq) = 1 / (Internal Freq) = 1/25KHz = 0.04ms = 40us ICN = Time Delay / ICT = 100us / 40 us = 2.5 cycles b) 4MHz oscillator Internal Freq = 4MHz/4 = 1MHz ICT = 1/1Mhz = 1us ICN = 100us / 1us = 100 cycles c) 16MHz oscillator Internal Freq = 16MHz/4 = 4MHz ICT = 1/4Mhz = 0.25us ICN = 100us / 0.25us = 400 cycles d) 32MHz oscillator Internal Freq = 32MHz/4 = 8MHz ICT = 1/8Mhz = 0.125us ICN = 100us / 0.125us = 800 cycles 1msec delay for 4MHz Oscillator: Internal Freq= 4/4MHz=1MHz ICT=1/1MHz=1us ICN=1ms/1us=1000 cycles We need to write a code that takes 1000 cycles for making 1miliseconds of delay.

6 LAB WORK 4 i. decfsz f, d: decrement f, skip if zero. If d=1, write the decremented value into file If d=0, write the decremented value into W ii. decf, d: decrement f iii. incfsz f, d: increment f, skip if zero iv. incf d: increment f v. sublw k: k-w, write the result of substation into W vi. subwf f, d: f-w, if d=1, write the result into file If d=0, write the result into W vii. rrf f, d: rotate right file viii. rlf f, d: rotate left file ix. comf f, d: complement f 2) Subroutines are often used to perform task that need to be performed frequently. This makes a program more structured in addition to saving memory space. In PIC16F84, call and return instructions are used for subroutines. The stack is read/write memory (RAM) used by the CPU to store some very critical information temporarily. This information usually is an address, but it could be data as well. The 14-bit core PICs have a stack of eight 13-bit registers which are exclusively used to hold subroutine return addresses. Remember that the Program counter is 13-bits wide to hold the 13-bit addresses for the Program store. 3) There is a loop inside loop. We are using subroutines to make a delay. Unless we are using subroutines, we need to write 1 million of nop command to create 1 second delay while using 4MHz oscillator. We need to compute the delay amount created by the following program segment: Counter_Outer equ 0x0C; free RAM location 12 Counter_Inner equ 0x0D; free RAM location 13 N equ.255; decimal constant 255 movlw N; 1cycle movwf Counter_Outer; 1cycle movwf Counter_Inner; 1cycle Loop_Outer movwf Counter_Inner; 1x255=255cycles Loop_Inner decfsz Counter_Inner, F; 1x255x255= 65025cycles goto Loop_Inner; 2x255x255= cycles decfsz Counter_Outer, F; 255 cycles goto Loop_Outer; 2x255=510 cycles

7 To find the delay amount, firstly, we need to find total numbers of cycles which is cycles cycles x 1us = msec delay 4) We need to write 1msec delay for 4MHz oscillator, for that need to write a subroutine that takes 1000 cycles. For example; Delay_1ms MOVLW h 0A ; W=.10 MOVWF R1 LOOP_1 MOVLW h 67 ; W=.100 MOVWF R2 LOOP_2 DECFSZ R2, GOTO LOOP_2 DECFSZ R1, f GOTO LOOP_1 RETURN END 5) We need to write 0.2sec delay for 4MHz oscillator. For example; Delay_0.2s MOVLW h FF MOVWF R1 LOOP_1 MOVLW h FF MOVWF R2 LOOP_2 DECFSZ R2, GOTO LOOP_2 DECFSZ R1, f GOTO LOOP_1 RETURN END 6) For 0.8sec delay for 4MHz oscillator, we need to write call delay_0.2s command 4 times. Because the maximum delay amount by using 2 loops is 0.2sec. 7) a) INCLUDE P16F84A.INC R1 EQU h 0C ; use loc 0DH for counter_1 R2 EQU h 0D ; use loc 0DH for counter_2 MEM EQU h 0E clrf PORTB BSF STATUS,5 CLRF TRISB BSF TRISA,0 BCF STATUS,5 CLRF MEM AGAIN BTFSS PORTA,0 GOTO AGAIN INCF MEM, f; MEM=MEM+1

8 MOVF MEM, W; W=MEM SUBLW d 10 ; W= 10-W BTFSC STATUS,2 GOTO ON GOTO AGAIN ON MOVLW h FF MOVWF PORTB CLRF PORTB LOOP GOTO LOOP DELAY_0.2S MOVLW h FF ; WREG=FF outer loop count value MOVWF R1; load FF into loc 25H (outer loop count) LOOP_1 MOVLW h FF ; WREG=FF inner loop count value MOVWF R2; load FF into loc 26H (inner loop count) LOOP_2 DECFSZ R2, f; decrement counter, skip if count=0 GOTO LOOP_2; repeat until count_2 becomes 0 DECFSZ R1, f; decrement counter, skip if count=0 GOTO LOOP_1; repeat until count_1 becomes 0 RETURN END - We need see the results of our program on experiment card. b) INCLUDE P16F84A.INC R1 EQU h 0C ; use loc 0DH for counter_1 R2 EQU h 0D ; use loc 0DH for counter_2 clrf PORTB BSF STATUS,5 CLRF TRISB BCF STATUS,5 LOOP MOVLW h FF MOVWF PORTB

9 CLRF PORTB MOVLW h 00 MOVWF PORTB LOOP GOTO LOOP DELAY_0.2S MOVLW h FF ; WREG=FF outer loop count value MOVWF R1; load FF into loc 25H (outer loop count) LOOP_1 MOVLW h FF ; WREG=FF inner loop count value MOVWF R2; load FF into loc 26H (inner loop count) LOOP_2 DECFSZ R2, f; decrement counter, skip if count=0 GOTO LOOP_2; repeat until count_2 becomes 0 DECFSZ R1, f; decrement counter, skip if count=0 GOTO LOOP_1; repeat until count_1 becomes 0 RETURN END We need see the results of our program on experiment card. c) INCLUDE P16F84A.INC R1 EQU h 0C ; use loc 0DH for counter_1 R2 EQU h 0D ; use loc 0DH for counter_2 clrf PORTB BSF STATUS,5 CLRF TRISB BCF STATUS,5 LOOP MOVLW h F0 MOVWF PORTB CLRF PORTB MOVLW h 0F MOVWF PORTB LOOP GOTO LOOP DELAY_0.2S MOVLW h FF ; WREG=FF outer loop count value MOVWF R1; load FF into loc 25H (outer loop count) LOOP_1

10 MOVLW h FF ; WREG=FF inner loop count value MOVWF R2; load FF into loc 26H (inner loop count) LOOP_2 DECFSZ R2, f; decrement counter, skip if count=0 GOTO LOOP_2; repeat until count_2 becomes 0 DECFSZ R1, f; decrement counter, skip if count=0 GOTO LOOP_1; repeat until count_1 becomes 0 RETURN END We need see the results of our program on experiment card. LAB WORK 5 The second bit of the STATUS Register is called Zero Bit or Z-Flag. If the result of the arithmetic or logic operation is 1 then Z-flag is 1, otherwise it is 0. 1) The following command do not affect the Z flag of the STATUS register movlw k movwf f swapf f, d 2) The following command affect the Z flag of the STATUS register, movf f, d clrf f 3) The following program segment clears the memory location 0x0C without affecting the Z flag of the STATUS register: Counter equ 0x0C; free RAM location 12 movlw 0; movwf Counter; loop goto loop; There is movlw and movwf command that affects the Z flag of the STATUS Register. In MPLAB, after building the code, Debugger-Select Tool-MPLAB SIM View-File Registers The address of the STATUS register is 03h and we need to observe the changes in 03h 4) The following program segment clears the memory location 0x0C affecting the Z flag of the STATUS register. Inspect the program segment below: Counter equ 0x0C; free RAM location 12 clrf Counter;

11 loop goto loop; There is not any command that affects the Z flag of the STATUS Register. Observe the value of the STATUS Register by using File Registers. 5) The following program transfers the content of 0x0C to PORTB without affecting the Z flag of the STATUS register. ; set PORTB as output port Counter equ 0x0C; free RAM location 12 movlw 0xF0; does not affect Z-flag movwf 0x0C; location 0x0C contains 0xF0, does not affect Z-flag swapf 0x0C, F; does not affect Z-flag swapf 0x0C, W; does not affect Z-flag movwf PORTB; does not affect Z-flag loop goto loop; The bit 1 of the STATUS Register is called Digit Carry/Barrow bit or DC-Flag In addition, operation if there is a carry from 4th low order bit of the result, DC=1, otherwise DC=0. In subtraction operation if barrow is needed from 4th low order bit of the result DC=0, if not DC=1 The bit 0 of the STATUS Register is called Carry/Barrow bit or C-Flag. At the of the addition operation, if there is a carry C-Flag is 1, if not it is 0. But at the of the subtraction, if barrow is needed, C-Flag is 0, otherwise it is 1. The following commands affect the carry-borrow flag of the STATUS register, addwf f, d subwf f, d addlw k sublw k 6) Trace the following program and see how half carry flag of the STATUS register is affected. bcf STATUS, 0; bcf STATUS, 1; bcf STATUS, 2; movlw 0x0F; does not affect Z-C-DC-flag addlw.1; affects all the flags, Z=0, DC=1, C=0 loop goto loop;

12 7) Trace the following program and see how carry flag of the STATUS register is affected. Note the content of the working register. bcf STATUS, 0; clear zero flag bcf STATUS, 1; clear half-carry flag bcf STATUS, 2; clear carry flag movlw 0x01; W= , affects all the flags sublw.0; a borrow is needed, carry flag is reset, h 00 -h 01, C=1, DC=0, C=0 loop goto loop; 8) bsf STATUS, RP0; clrf TRISB; bcf STATUS, RP0; clrf PORTB; bcf STATUS, 0; Z=0 bcf STATUS, 1; DC=0 bcf STATUS, 2; C=0 movlw 0xFF; W= FF addlw.1; W+.1=255+1=0, Z=1, DC=1, C=1, affects all the flags movwf PORTB; does not affect the flags loop goto loop; 9) bcf STATUS,0; Z=0 bcf STATUS,1; DC=0 bcf STATUS,2; C=0 movlw 0xFF; does not affect Z-C-DC-flag, W=h FF addlw.1; affects all the flags, 255+1=0, Z=1, C=1, DC=1 bcf STATUS,1; clear half carry flag bcf STATUS,0; clear zero flag movlw.1; W=h 01 sublw.0; affects all the flags, h 00 -h 01, Z=0, DC=0, C=0 loop goto loop;

13 LAB WORK 6 1) 13-bit Program counter which acts as an Instruction pointer addressing the instruction currently being fetched into the pipeline. The Program counter potentially can address up to 2^13 = 8K = 8192 instructions, although the PIC16F84A has only 1,024 = 1K instruction capacity. The Program counter normally increments up from instruction 1 at location h 000, but can skip or jump if commanded by a relevant instruction. Program counter (PC) is 13-bit; low 8-bit is PCL and high 5-bit is PCH. 10-bits are used for PIC16F84A. PCLATH is used to write data to PCH After building the code, Debugger-MPLAB SIM View-File Registers Trace the code with F7 button The address of the PCL is 02h so we will observe the changes in this address. Every time, when we push F7, the value of PCL will increase by 1. But after Call Subroutine_A command the value of PCL will become 0E which is 14 in decimal. Subroutine_A starts in the line 14, so that value of PCL will also become 14. When the subroutine s, with RETURN command the value of PCL will become 05h because 05h is where we are before we call the subroutine. 2) bcf STATUS, 0; clear carry flag bcf STATUS, 1; clear half-carry flag bcf STATUS, 2; clear zero flag movlw.1; movlw b' ' sublw.3; borrow is not needed, carry and half-carry-flags are set sublw b' ' movlw.5; b' ' sublw.2; b' '; borrow is needed from low and high nibbles, carry and halfbarrow flags are reset movlw b' '; sublw b' '; only half carry-flag is set, carry flag is reset loop goto loop; This time, we need to observe the changes in STATUS register in File Registers. The address of the STATUS Register is 03h. At the beginning the value of the STATUS Register is 18h which is , all flags are 0. After the subtraction operation (3-1), barrow is not needed neither low nor high nibbles, the value of the STATUS Register will become 1Bh which is , carry and half carry flags will become 1 but z flag does not affect because the result won t be 0. After the subtraction (2-5), barrow will be needed from either low and high nibbles, C and DC flags will become 0, Z-flag won t be affected. The value of the STATUS Register become which is 18h.

14 After the subtraction operation of (1-128) only half carry flag will be 1, carry flag will be 0, the value of the STATUS Register will become 0Ah which is ) If the numbers greater than 1 byte (8 bit), we can subtract these numbers using 16-bit subtraction. When subtracting two 16-bit data operands, we need to be concerned with the propagation of a carry from the lower byte to the higher byte. When the first byte is subtracted, there is a carry (E7-8D=59, C=1, positive). Subtract high byte directly. After the low byte subtraction; If C=0 subtract 1 from high byte of first number. And then subtract higher bytes. And control the carry again. If C=1, show output directly. If C=0, take 2 s complement of output and show the result. AL equ 0x0C AH equ 0x0D BL equ 0x0E BH equ 0x0F RL equ 0x10; low byte result RH equ 0x11; high byte result ; A=0x1206 movlw 0x06; movwf AL; movlw 0x12; movwf AH; ; B=0x0814 movlw 0x14; movwf BL; movlw 0x08; movwf BH; subtraction_operation movf BL, W; subwf AL, W; affects the status flags movwf RL; does not affect the status flags. Low-byte result is written to location RL btfss STATUS, 0; btfss STATUS, C; check carry flag for zero, if barrow is needed (c=0), decrement AH if not skip the next line decf AH, F; movf BH, W; subwf AH, W; movwf RH; high-byte result is written to location RH

15 LAB WORK 7 In this work, we will do seven segment display control by using PIC Microcontroller. 1) RETLW (Return with literal in W); The working register is loaded with the 8-bit literal k. The program counter is loaded from the top of the stack (the return address) syntax: RETLW k ; W=k 2) First of all, in this code,.2 (decimal 2) is written into w-register. Then, look up table is called. In the look up table, in the first line there is addwf PCL,f it adds contents of the PCL and W Register. PCL is the lower 8 bits of the Program Counter. So that, the pointer will jump 2 lines(to the RETLW h 02 ), in the other words, it will write h 02 into W-Register and exit from the Look Up Table. Then, the contents of W-Reg will be written into PORTB. 3) There is an another Look Up Table, we need to update the look up table in question 2 with this one. It will write h FF into W-Register and exit from the Look Up Table. Then, the contents of W-Reg will be written into PORTB. 4) Contents of the PORTB: i) PORTB=h 0F ii) PORTB=h BB iii) PORTB=h 44 iv) PORTB=h 00 v) PORTB=h FF 5) Hex.num output bits data in 7-segment pins number in 7-segment display for PORTB gfedcba h 00 h 3F h 01 h h 02 h 5B h 03 h 4F h 04 h h 05 h 6D h 06 h 7D h 07 h h 08 h 7F h 09 h 6F h 0A h A h 0B h 7C B h 0C h C h 0D h 5E D h 0E h E h 0F h F NOKTA h R1 EQU 0X0C

16 R2 EQU 0X0D COUNTER_REG EQU 0X0E bsf STATUS, RP0; clrf TRISB; bcf STATUS, RP0; clrf PORTB; CLRF COUNTER_REG main_part MOVF COUNTER_REG,W; call my_lookup_table; movwf PORTB; CALL DELAY CALL DELAY CALL DELAY MOVLW.10 SUBWF COUNTER_REG,0; BTFSC STATUS,2; CLRF COUNTER_REG BTFSS STATUS,2; INCF COUNTER_REG,F; GOTO main_part; DELAY MOVLW h'ff' ; 1 cycle MOVWF R1 ; 1 cycle LOP_1 MOVLW h'ff' ;1xM (M=number in R1) MOVWF R2 ; 1xM LOP_2 DECFSZ R2,f ; 1xMxN (N=number in R2) GOTO LOP_2 ; 2xMxN DECFSZ R1,f ; 1xM GOTO LOP_1 ; 2xM RETURN ;2 cycle my_lookup_table addwf PCL, F; retlw 0x3F retlw 0x06 retlw 0x5B retlw 0x4F retlw 0x66 retlw 0x6D

17 retlw 0x7D retlw 0x07 retlw 0x7F retlw 0x6F retlw 0x77 retlw 0x7C retlw 0x39 retlw 0x5E retlw 0x79 retlw 0x71 retlw 0x80 6) R1 EQU 0X0C R2 EQU 0X0D COUNTER_REG EQU 0X0E bsf STATUS, RP0; clrf TRISB; bcf STATUS, RP0; clrf PORTB; CLRF COUNTER_REG main_part MOVF COUNTER_REG,W; call my_lookup_table; movwf PORTB; CALL DELAY CALL DELAY CALL DELAY MOVLW.5 SUBWF COUNTER_REG,0; BTFSC STATUS,2; CLRF COUNTER_REG BTFSS STATUS,2; INCF COUNTER_REG,F; GOTO main_part; DELAY MOVLW h'ff' ; 1 cycle MOVWF R1 ; 1 cycle LOP_1 MOVLW h'ff' ;1xM (M=number in R1) MOVWF R2 ; 1xM

18 LOP_2 DECFSZ R2,f ; 1xMxN (N=number in R2) GOTO LOP_2 ; 2xMxN DECFSZ R1,f ; 1xM GOTO LOP_1 ; 2xM RETURN ;2 cycle my_lookup_table addwf PCL, F; retlw 0x3F retlw 0x5B retlw 0x66 retlw 0x7D retlw 0x7F LAB WORK 8 1) org 0x00; address of main program org 0x04; address of ISR In MPLAB, Debugger-Select Tool-MPLAB SIM Debugger-Stimulus-New Workbook For Pin select RP0 For Action select toggle Debugger-Animate It is in infinite loop, it have not entered in ISR part. When we click Fire in Workbook we are creating an interrupt originated from RB0. 2) When we trace the program, using stimulus it gives only one interrupt and the program enters into an infinite loop. The reason is there is not any goto my_isr part 3) When we trace the program, using stimulus it gives only one interrupt and the program enters into an infinite loop again. The difference from the previous question is, in ISR the related flag is not cleared. 4) In MPLAB, Debugger-Stimulus-New Workbook For Pin select RB4,RB5,RB6,RB7(any of them can be chosen) For Action select toggle It is in infinite loop, it have not entered in ISR part. When we click Fire in Workbook we are creating an interrupt originated from RB pins. 5) HomeWork

19 LAB WORK 9 1) In this program timer interrupt is enabled and as clock course RA4/TOCKI is used. When we s pulses to RA4 using stimulus, there will be an interrupt. When we click 512 times to fire button in the workbook, there will be an interrupt. 2) In this question, there is a number in TMR0 which is 253 which means the clock starts counting from 253. When we click 6 times to fire button in the workbook, there will be an interrupt. 3) bcf OPTION_REG, T0CS; At each clock cycle, timer value will be incremented bsf OPTION_REG, PSA; Prescalar value is assigned to WDT by default So, in this code internal clock is used and its value is incremented at each clock cycle. When timer register TMR0 counts from h FF to h 00 the interrupt will be occur simultaneously. It will take 255 cycles. 4) In this question, TMR0 starts counting from.240 so that after 16 cycles, the interrupt will be occur 5) In this question, the difference from previous question, the timer value is incremented every 2 clock cycles. So that, after 32 cycles interrupt will be occur LAB WORK 10 1) We are using Watch Dog Timer as a counter. There is prescalar value for WDT, prescalar value bits are PS0, PS1 and PS2. These bits are all 0. From the table of prescalar value, WDT will be incremented at each clock cycle. 2) In this question, 001 is assigned as a prescalar value to the WDT. From the table, WDT will be incremented at 2 clock cycles. 3) The difference between this question and the first one is there is SLEEP command. When we are using WDT, SLEEP command makes Bit-4 of the STATUS register (TO ) 1 on reset or when WDT is cleared and makes Bit-3 of the STATUS register (PD) 0. It has value 0 when WDT overflows. In addition, the prescalar value of WDT will be set as ) There is an interrupt which is originated from RB0. Again, there is a SLEEP command but this time, there is not any prescalar value and we are using Internal Clock.

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

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

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

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

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

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

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

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

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

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

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

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

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

16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution

16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution 16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling

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

Chapter 5 Sections 1 6 Dr. Iyad Jafar

Chapter 5 Sections 1 6 Dr. Iyad Jafar Building Assembler Programs Chapter 5 Sections 1 6 Dr. Iyad Jafar Outline Building Structured Programs Conditional Branching Subroutines Generating Time Delays Dealing with Data Example Programs 2 Building

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

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

16.317: Microprocessor-Based Systems I Summer 2012

16.317: Microprocessor-Based Systems I Summer 2012 16.317: Microprocessor-Based Systems I Summer 2012 Exam 3 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling

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

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 5 Solution

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 5 Solution For each of the following complex operations, write a sequence of PIC 16F1829 instructions that performs an equivalent operation. Assume that X, Y, and Z are 16-bit values split into individual bytes as

More information

D:\PICstuff\PartCounter\PartCounter.asm

D:\PICstuff\PartCounter\PartCounter.asm 1 ;********************************************************************** 2 ; This file is a basic code template for assembly code generation * 3 ; on the PICmicro PIC16F84A. This file contains the basic

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

ECE Test #1: Name

ECE Test #1: Name ECE 376 - Test #1: Name Closed Book, Closed Notes. Calculators Permitted. September 23, 2016 20 15 10 5 0

More information

16.317: Microprocessor-Based Systems I Spring 2012

16.317: Microprocessor-Based Systems I Spring 2012 16.317: Microprocessor-Based Systems I Spring 2012 Exam 3 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling

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

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

CONNECT TO THE PIC. A Simple Development Board

CONNECT TO THE PIC. A Simple Development Board CONNECT TO THE PIC A Simple Development Board Ok, so you have now got your programmer, and you have a PIC or two. It is all very well knowing how to program the PIC in theory, but the real learning comes

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

Section 31. Instruction Set

Section 31. Instruction Set 31 HIGHLIGHTS Section 31. Instruction Set Instruction Set This section of the manual contains the following major topics: 31.1 Introduction... 31-2 31.2 Data Memory Map... 31-3 31.3 Instruction Formats...

More information

16.317: Microprocessor Systems Design I Fall 2015

16.317: Microprocessor Systems Design I Fall 2015 16.317: Microprocessor Systems Design I Fall 2015 Exam 2 Solution 1. (16 points, 4 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling

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

Application Note - PIC Source Code v1.1.doc

Application Note - PIC Source Code v1.1.doc Programmable, RGB-backlit LCD Keyswitches APPLICATION NOTE PIC SOURCE CODE 2004-2006 copyright [E³] Engstler Elektronik Entwicklung GmbH. All rights reserved. PIC Source Code The following Assembler source

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

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

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

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

/* PROGRAM FOR BLINKING LEDs CONEECTED TO PORT-D */

/* PROGRAM FOR BLINKING LEDs CONEECTED TO PORT-D */ /* PROGRAM FOR BLINKING LEDs CONEECTED TO PORT-D */ CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _HS_OSC & _WRT_OFF & _LVP_OFF & _CPD_OFF ;***** VARIABLE DEFINITIONS COUNT_L EQU 0x01 ;**********************************************************************

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

/ 40 Q3: Writing PIC / 40 assembly language TOTAL SCORE / 100 EXTRA CREDIT / 10

/ 40 Q3: Writing PIC / 40 assembly language TOTAL SCORE / 100 EXTRA CREDIT / 10 16.317: Microprocessor-Based Systems I Summer 2012 Exam 3 August 13, 2012 Name: ID #: Section: For this exam, you may use a calculator and one 8.5 x 11 double-sided page of notes. All other electronic

More information

Arithmetic,logic Instruction and Programs

Arithmetic,logic Instruction and Programs Arithmetic,logic Instruction and Programs 1 Define the range of numbers possible in PIC unsigned data Code addition and subtraction instructions for unsigned data Perform addition of BCD Code PIC unsigned

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

PTK8756B 8 Bit Micro-controller Data Sheet

PTK8756B 8 Bit Micro-controller Data Sheet PTK8756B 8 Bit Micro-controller DEC 15, 2008 Ver1.1 普泰半導體股份有限公司 PORTEK Technology Corporation 公司地址 : 臺北縣新店市寶橋路 235 巷 120 號 4 樓 聯絡電話 : 886-2-89121055 傳真號碼 : 886-2-89121473 公司網址 : www.portek.com.tw Page1

More information

A Better Mouse Trap. Consumer Appliance, Widget, Gadget APPLICATION OPERATION: Ontario, Canada

A Better Mouse Trap. Consumer Appliance, Widget, Gadget APPLICATION OPERATION: Ontario, Canada A Better Mouse Trap Author: APPLICATION OPERATION: My application uses a PIC12C508 to produce realistic sounding mouse-like coos that all mice are sure to find seductive. The entire circuit should be imbedded

More information

PIC PROGRAMMING START. The next stage is always the setting up of the PORTS, the symbol used to indicate this and all Processes is a Rectangle.

PIC PROGRAMMING START. The next stage is always the setting up of the PORTS, the symbol used to indicate this and all Processes is a Rectangle. PIC PROGRAMMING You have been introduced to PIC chips and the assembly language used to program them in the past number of lectures. The following is a revision of the ideas and concepts covered to date.

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

ME 515 Mechatronics. A microprocessor

ME 515 Mechatronics. A microprocessor ME 515 Mechatronics Microcontroller Based Control of Mechanical Systems Asanga Ratnaweera Department of Faculty of Engineering University of Peradeniya Tel: 081239 (3627) Email: asangar@pdn.ac.lk A microprocessor

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

Performance & Applications

Performance & Applications EE25M Introduction to microprocessors original author: Feisal Mohammed updated: 15th March 2002 CLR Part VI Performance & Applications It is possible to predict the execution time of code, on the basis

More information

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

Chapter 3: Further Microcontrollers

Chapter 3: Further Microcontrollers Chapter 3: Further Microcontrollers Learning Objectives: At the end of this topic you will be able to: recall and describe the structure of microcontrollers as programmable assemblies of: memory; input

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

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

Experiment 7:The USART

Experiment 7:The USART University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory 0907334 7 Experiment 7:The USART Objectives Introduce the USART module of the PIC

More information

Arithmetic and Logic Instructions. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

Arithmetic and Logic Instructions. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan Arithmetic and Logic Instructions Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan chanhl@mail.cgu.edu.tw Find the sum of the values from 40H to 43H. Put the sum in filereg locations

More information

SOLAR TRACKING SYSTEM USING PIC16F84A STEPPER MOTOR AND 555TIMER

SOLAR TRACKING SYSTEM USING PIC16F84A STEPPER MOTOR AND 555TIMER SOLAR TRACKING SYSTEM USING PIC16F84A STEPPER MOTOR AND 555TIMER Amey Arvind Madgaonkar 1, Sumit Dhere 2 & Rupesh Ratnakar Kadam 3 1. Block diagram International Journal of Latest Trends in Engineering

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

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

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

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

16.317: Microprocessor Systems Design I Spring 2015

16.317: Microprocessor Systems Design I Spring 2015 16.317: Microprocessor Systems Design I Spring 2015 Exam 2 Solution 1. (16 points, 4 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by

More information

ECE 354 Computer Systems Lab II. Interrupts, Strings, and Busses

ECE 354 Computer Systems Lab II. Interrupts, Strings, and Busses ECE 354 Computer Systems Lab II Interrupts, Strings, and Busses Fun Fact Press release from Microchip: Microchip Technology Inc. announced it provides PICmicro field-programmable microcontrollers and system

More information

ECE 354 Introduction to Lab 2. February 23 rd, 2003

ECE 354 Introduction to Lab 2. February 23 rd, 2003 ECE 354 Introduction to Lab 2 February 23 rd, 2003 Fun Fact Press release from Microchip: Microchip Technology Inc. announced it provides PICmicro field-programmable microcontrollers and system supervisors

More information

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

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

More information

SOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!!

SOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!! THE UNIVERSITY OF THE WEST INDIES EXAMINATIONS OF APRIL MID-TERM 2005 Code and Name of Course: EE25M Introduction to Microprocessors Paper: MidTerm Date and Time: Thursday April 14th 2005 8AM Duration:

More information

APPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with a PIC Microcontroller

APPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with a PIC Microcontroller Maxim/Dallas > App Notes > REAL-TIME CLOCKS Keywords: DS1305, SPI, PIC, real time clock, RTC, spi interface, pic microcontroller Aug 20, 2003 APPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with

More information

Interfacing PIC Microcontrollers. ADC8BIT2 Schematic. This application demonstrates analogue input sampling

Interfacing PIC Microcontrollers. ADC8BIT2 Schematic. This application demonstrates analogue input sampling Interfacing PIC Microcontrollers ADC8BIT2 Schematic This application demonstrates analogue input sampling A manually adjusted test voltage 0-5V is provided at AN0 input A reference voltage of 2.56V is

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

16.317: Microprocessor-Based Systems I Fall 2012

16.317: Microprocessor-Based Systems I Fall 2012 16.317: Microprocessor-Based Systems I Fall 2012 Exam 2 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling

More information

When JP1 is cut, baud rate is Otherwise, baud rate is Factory default is that JP1 is shorted. (JP1 is jumper type in some model)

When JP1 is cut, baud rate is Otherwise, baud rate is Factory default is that JP1 is shorted. (JP1 is jumper type in some model) ELCD SERIES INTRODUCTION ALCD is Serial LCD module which is controlled through Serial communication. Most of existing LCD adopts Parallel communication which needs lots of control lines and complicated

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

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

APPLICATION NOTE Wire Communication with a Microchip PICmicro Microcontroller

APPLICATION NOTE Wire Communication with a Microchip PICmicro Microcontroller Maxim > App Notes > 1-Wire DEVICES BATTERY MANAGEMENT Keywords: 1-wire, PICmicro, Microchip PIC, 1-Wire communication, PIC microcontroller, PICmicro microcontroller, 1 wire communication, PICs, micros,

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

ALU and Arithmetic Operations

ALU and Arithmetic Operations EE25M Introduction to microprocessors original author: Feisal Mohammed updated: 6th February 2002 CLR Part IV ALU and Arithmetic Operations There are several issues connected with the use of arithmetic

More information

The University of Texas at Arlington Lecture 5

The University of Texas at Arlington Lecture 5 The University of Texas at Arlington Lecture 5 CSE 3442/5442 LCD Discussed in Chapter 12 RS, R/W, E Signals Are Used to Send/Receive Data on D0-D7 2 PIC PROGRAMMING IN C CHAPTER 7 Chapter 7 discusses the

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

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

Weekly Report: Interactive Wheel of Fortune Week 4 02/014/07-02/22/07 Written by: Yadverinder Singh

Weekly Report: Interactive Wheel of Fortune Week 4 02/014/07-02/22/07 Written by: Yadverinder Singh Work Completed: Weekly Report: Interactive Wheel of Fortune Week 4 02/014/07-02/22/07 Written by: Yadverinder Singh Last week started with the goal to complete writing the overall program for the game.

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

CHAPTER 6 CONCLUSION AND SCOPE FOR FUTURE WORK

CHAPTER 6 CONCLUSION AND SCOPE FOR FUTURE WORK 134 CHAPTER 6 CONCLUSION AND SCOPE FOR FUTURE WORK 6.1 CONCLUSION Many industrial processes such as assembly lines have to operate at different speeds for different products. Process control may demand

More information

PART TWO LISTING 8 PROGRAM TK3TUT8 MOVF PORTA,W ANDLW B ADDWF COUNT,F MOVF COUNT,W MOVWF PORTB GOTO LOOP

PART TWO LISTING 8 PROGRAM TK3TUT8 MOVF PORTA,W ANDLW B ADDWF COUNT,F MOVF COUNT,W MOVWF PORTB GOTO LOOP EPE PIC TUTORIAL V2 JOHN BECKER PART TWO Quite simply the easiest low-cost way to learn about using PIC Microcontrollers! EPE PIC TUTORIAL In this part we play with switches, make noises, count times,

More information

The University of Texas at Arlington Lecture 7

The University of Texas at Arlington Lecture 7 The University of Texas at Arlington Lecture 7 CSE 3442/5442 Agenda HW 2 due today Begin Chapter 5 In class assignment. Reading Assignment for Tuesday, Continue Reading Chapter 6. Assignment 3 and 4 due

More information

Chapter 11: Interrupt On Change

Chapter 11: Interrupt On Change Chapter 11: Interrupt On Change The last two chapters included examples that used the external interrupt on Port C, pin 1 to determine when a button had been pressed. This approach works very well on most

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

Lesson 4 Fun with W and F

Lesson 4 Fun with W and F Elmer 160 Lesson 4 Overview Lesson 4 Introduction In this section This lesson introduces the first few PIC instructions. The following is a list of topics in this section: Description See Page Writing

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

Chapter 3 BRANCH, CALL, AND TIME DELAY LOOP

Chapter 3 BRANCH, CALL, AND TIME DELAY LOOP Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 3022: Embedded Systems Discussion Chapter 3 BRANCH, CALL, AND TIME DELAY LOOP Eng. Eman R. Habib February, 2014 2 Embedded

More information

PIC Discussion By Eng. Tamar Jomaa

PIC Discussion By Eng. Tamar Jomaa PIC Discussion By Eng. Tamar Jomaa 1 Write assembly language instructions to clear the general purpose registers of PIC16F84A microcontroller (don t write the whole program) 2 Islamic university Electrical

More information

More (up a level)... Connecting the Nokia 3510i LCD to a Microchip PIC16F84 microcontroller

More (up a level)... Connecting the Nokia 3510i LCD to a Microchip PIC16F84 microcontroller 1 von 8 24.02.2010 21:53 More (up a level)... Connecting the Nokia 3510i LCD to a Microchip PIC16F84 microcontroller As with the FPGA board previously, the connections are made by soldering standard IDC

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 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

Model Answer Microcontrollers. MCQ Problems Total Q1 Q2

Model Answer Microcontrollers. MCQ Problems Total Q1 Q2 Model Answer Course name: Microcontrollers Exam numer: Midterm - Fall 2017 Course Code: ECE401 Exam Date: Nov 2016 Lecturer: Dr. Ahmed ElShafee Time Allowed: 60 minutes ID:... Name:.... MCQ Prolems Total

More information

DESIGN AND FABRICATION OF FARE METER OF TAXICAB USING MICROCONTROLLER

DESIGN AND FABRICATION OF FARE METER OF TAXICAB USING MICROCONTROLLER Proceedings of the International Conference on Mechanical Engineering 00 (ICME00) 8-0 December 00, Dhaka, Bangladesh ICME0-AM-0 DESIGN AND FABRICATION OF FARE METER OF TAXICAB USING MICROCONTROLLER Md.

More information

Appendix D: Source Codes. PDF created with pdffactory Pro trial version

Appendix D: Source Codes. PDF created with pdffactory Pro trial version Appendix D: Source Codes Accelerometer Acquisition program (MPLAB) List p=16f877a include "p16f877a.inc" config _cp_off & _wdt_off & _xt_osc & _pwrte_on ;Reading Accelerometer duty cycle value ;This subroutine

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

Jordan University of Science and Technology Electrical Engineering Department Microcontrollers and Embedded Systems Spring 2011

Jordan University of Science and Technology Electrical Engineering Department Microcontrollers and Embedded Systems Spring 2011 Jordan University of Science and Technology Electrical Engineering Department Microcontrollers and Embedded Systems Spring 2011 Microcontrollers andembedded Systems and and EE445 Embedded Embedded Microcontrollers

More information

PIC Architecture & Assembly Language Programming. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

PIC Architecture & Assembly Language Programming. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan PIC Architecture & Assembly Language Programming Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan chanhl@mail.cgu.edu.tw ALU with working register (WREG) and literal value 2 MOVLW

More information