KHAWAJA ABDUL SAMAD FA19-EEE-006 COMSATS University Islamabad, Abbottabad Campus Department of Electrical & Computer Engineering Laboratory Report Microprocessor Systems and Interfacing CPE-342 KHAWAJA ABDUL SAMD FA19-EEE-006 6R KHAWAJA ABDUL SAMAD FA19-EEE-006 LAB:8 Question1. Generate a rectangular wave with PIC18F452 microcontroller with following requirements. i. Frequency= 200Hz, Duty Cycle =20% & XTAL =20 MHz ii. Frequency= 50Hz, Duty Cycle =25% & XTAL =40 MHz iii. Frequency=1Hz, Duty Cycle =50% & XTAL =40 MHz iv. Frequency=4Hz, Duty Cycle =25% & XTAL =20 MHz Code i. Frequency= 200Hz, Duty Cycle =20% & XTAL =20 MHz #INCLUDE <P18F452.INC> LIST P=PIC18F452, F=INHX32, N=0, ST=OFF, R=HEX config OSC=HS, OSCS=OFF, WDT=OFF, BORV=45, PWRT=ON, BOR=ON, DEBUG=OFF, LVP=OFF, STVR=OFF ORG 0x2A BCF TRISC, 0 AGAIN BSF PORTC, 0 CALL X1 BCF PORTC,0 CALL X1 CALL X1 CALL X1 CALL X1 BRA AGAIN X1 MOVLW B'00001000' MOVWF T0CON MOVLW H'EC' MOVWF TMR0H MOVLW 76H KHAWAJA ABDUL SAMAD MOVWF TMR0L BCF INTCON, TMR0IF BSF T0CON, TMR0ON XYZ BTFSS INTCON,TMR0IF BRA XYZ BCF T0CON, TMR0ON RETURN END Screenshot FA19-EEE-006 KHAWAJA ABDUL SAMAD Output ii. Frequency= 50Hz, Duty Cycle =25% & XTAL =40 MHz Code #INCLUDE <P18F452.INC> LIST P=PIC18F452, F=INHX32, N=0, ST=OFF, R=HEX config OSC=HS, OSCS=OFF, WDT=OFF, BORV=45, PWRT=ON, BOR=ON, DEBUG=OFF, LVP=OFF, STVR=OFF ORG 0x2A BCF TRISC, 0 AGAIN BSF PORTC, 0 CALL X1 BCF PORTC,0 CALL X1 CALL X1 CALL X1 BRA AGAIN X1 MOVLW B'00001000' MOVWF T0CON MOVLW H'3C' MOVWF TMR0H MOVLW H'B0' MOVWF TMR0L BCF INTCON, TMR0IF FA19-EEE-006 KHAWAJA ABDUL SAMAD BSF T0CON, TMR0ON XYZ BTFSS INTCON, TMR0IF BRA XYZ BCF T0CON, TMR0ON RETURN END Screenshot Output FA19-EEE-006 KHAWAJA ABDUL SAMAD FA19-EEE-006 iii. Frequency=1Hz, Duty Cycle =50% & XTAL =40 MHz Code #INCLUDE <P18F452.INC> LIST P=PIC18F452, F=INHX32, N=0, ST=OFF, R=HEX config OSC=HS, OSCS=OFF, WDT=OFF, BORV=45, PWRT=ON, BOR=ON, DEBUG=OFF, LVP=OFF, STVR=OFF ORG 0X2A BCF TRISC,0 AGAIN BSF PORTC,0 CALL D1 BCF PORTC,0 CALL D1 BRA AGAIN D1 MOVLW B'00000110' MOVWF T0CON MOVLW H'67' MOVWF TMR0H MOVLW H'69' MOVWF TMR0L BCF INTCON,TMR0IF BSF T0CON,TMR0ON . ABC BTFSS INTCON,TMR0IF BRA ABC BCF T0CON,TMR0ON RETURN END KHAWAJA ABDUL SAMAD Screenshot Output FA19-EEE-006 KHAWAJA ABDUL SAMAD iv. Frequency=4Hz, Duty Cycle =25% & XTAL =20 MHz Code #INCLUDE <P18F452.INC> LIST P=PIC18F452, F=INHX32, N=0, ST=OFF, R=HEX config OSC=HS, OSCS=OFF, WDT=OFF, BORV=45, PWRT=ON, BOR=ON, DEBUG=OFF, LVP=OFF, STVR=OFF ORG 0x2A BCF TRISC, 0 AGAIN BSF PORTC, 0 CALL X1 BCF PORTC,0 CALL X1 CALL X1 CALL X1 BRA AGAIN X1 MOVLW B'00000101' MOVWF T0CON MOVLW H'EC' MOVWF TMR0H MOVLW H'EB' MOVWF TMR0L BCF INTCON, TMR0IF BSF T0CON, TMR0ON XYZ BTFSS INTCON, TMR0IF BRA XYZ BCF T0CON, TMR0ON RETURN END FA19-EEE-006 KHAWAJA ABDUL SAMAD Screenshot Output FA19-EEE-006 KHAWAJA ABDUL SAMAD Fill the Following table from above programs FA19-EEE-006 KHAWAJA ABDUL SAMAD FA19-EEE-006 Question2 Implement a RADAR System using PIC18F452. Radar system uses a listening sensor and listens for high value from sensor. Once it detects high value from sensor it will generate a pulse with duration of 300ms. Use XTAL=24 MHz with PIC18F452. Code #INCLUDE P18F452.INC LIST P=PIC18F452, F=INHX32, N=0, ST=OFF, R=HEX config OSC=HS, OSCS=OFF, WDT=OFF, BORV=45, PWRT=ON, BOR=ON, DEBUG=OFF, LVP=OFF, STVR=OFF ORG 2AH BCF TRISC, RC0 MOVLW 04H MOVWF T0CON AGAIN MOVLW 24H MOVWF TMR0H MOVLW 47H MOVWF TMR0L BCF INTCON,TMR0IF SENSORCHECK BTFSS PORTB,RB0 BRA SENSORCHECK BSF PORTC,RC0 BSF T0CON,TMR0ON ROLLOVERCHECK BTFSS INTCON,TMR0IF BRA ROLLOVERCHECK BCF T0CON,TMR0ON BCF PORTC,RC0 KHAWAJA ABDUL SAMAD BRA AGAIN END Screenshot FA19-EEE-006 KHAWAJA ABDUL SAMAD Output FA19-EEE-006 Laboratory Assessment Criteria Allocated Marks Psychomotor (evaluated during the experiment) 60% Criteria Allocated Marks Affective (Evaluated during the Lab) Criteria Cognitive (evaluated on report submission) Learning Level Poor Good Very Good Excellent 40% 50-60% 70-80% 90-100% Learning Level Poor Good Very Good Excellent 40% 50-60% 70-80% 90-100% Obtained Marks (A) 10% Allocated Marks Learning Level Poor Good Very Good Excellent 40% 50-60% 70-80% 90-100% 30% Obtained Marks= (0.6 × P) + (0.1 × A) + (0.3 × C) = Course Instructor: Obtained Marks (P) : Total Marks: Obtained Marks (C)