NATIONAL UNIVERSITY OF SCIENCES AND TECHNOLOGY School of Electrical Engineering and Computer Sciences LAB REPORT 1 MICROPROCESSOR SYSTEMS BEE15-D Submitted To : Mr Muhammad Adnan Submitted By : Farhan Tariq (480608) Shamel Mujtaba (467948) Qasim Ali (469380) Khwaja Ibrahim (463113) OBJECTIVES 1. To Create Project in Atmel Studio 2. To Simulate Assembly code for AVR ATmega328p 3. To Burn Hex file in ATmega328p using an Arduino Uno board. Hardware Used : Atmega 328p , LEDs , Arduino Cable CODE ; Initial constants ldi R16, 0b11111111 ; Load immediate value 0xFF into register R16 ldi R17, 0b11111111 ; Load immediate value 0xFF into register R17 ; Set DDRA as output out DDRD, R17 ; Output the value of register R17 to the DDRA register ; Code to toggle LEDs toggler: subi R16, 0b11111111 ; Subtract immediate value 0xFF from register R16 out PORTD, R16 ; Output the value of register R16 to the PORTA register rjmp idle_loop ; Jump to the idle_loop ; Delay loop idle_loop: ldi R19, 0xFF ; Load immediate value 0xFF into register R19 ldi R20, 0xFF ; Load immediate value 0x0F into register R20 ldi R21, 0x10 ; Load immediate value 0x01 into register R21 idle_loop_0: idle_loop_1: idle_loop_2: dec R19 ; Decrement register R19 brne idle_loop_2 ; Branch to idle_loop_2 if R19 is not equal to zero dec R20 ; Decrement register R20 brne idle_loop_1 ; Branch to idle_loop_1 if R20 is not equal to zero dec R21 ; Decrement register R21 brne idle_loop_0 ; Branch to idle_loop_0 if R21 is not equal to zero rjmp toggler ; Jump back to toggle TASK 1 Does the implementation follow simulation? Time blinking of any reasonable LED and compare it with simulation. Document these comparisons and observations. Iteration 1 Cycle Counter I T H S V N Z C 0 0 1 0 0 0 0 1 Cycles 43312498 Time 207ms R16 0x01 PORTA 0 0 0 0 0 0 0 0 Cycle Counter I T H S V N Z C 0 0 0 1 0 1 0 0 Cycles 1989162 Time 124ms R16 0x01 PORTA 0 0 0 0 0 0 0 0 Cycle Counter I T H S V N Z C 0 0 1 0 0 0 0 1 Cycles 4924927 Time 307ms R16 0x02 PORTA 0 0 0 0 0 0 0 0 I T H S V N Z C Iteration 2 Iteration 3 Iteration 4 Cycle Counter 0 0 1 0 0 0 0 1 Cycles 6955335 Time 434ms R16 0x03 PORTA 0 0 0 0 0 0 0 0 Cycle Counter I T H S V N Z C 0 0 1 0 0 0 0 1 Cycles 8489889 Time 530ms R16 0x04 PORTA 0 0 0 0 0 0 0 0 Cycle Counter I T H S V N Z C 0 0 1 0 0 0 0 1 Cycles 9912170 Time 619ms R16 0x05 PORTA 0 0 0 0 0 0 0 0 Cycle Counter I T H S V N Z C 0 0 1 0 0 0 0 1 Cycles 10056932 Time 809ms R16 0x06 PORTA 0 0 0 0 0 0 0 0 Iteration 5 Iteration 6 Iteration 7 Iteration 8 Cycle Counter I T H S V N Z C 0 0 1 0 0 0 0 1 Cycles 10197210 Time 912ms R16 0x07 PORTA 0 0 0 0 0 0 0 0 Cycle Counter I T H S V N Z C 0 0 1 0 0 0 Cycles 12105921 Time 991ms R16 0x08 PORTA 0 0 0 0 0 0 0 0 Cycle Counter I T H S V N Z C 0 0 1 0 0 0 Cycles 13582198 Time 1043ms R16 0x09 PORTA 0 0 0 0 0 0 0 0 Cycle Counter I T H S V N Z C 0 0 0 0 0 0 1 0 Cycles 4 Time 4us R16 0x00 Iteration 9 1 Iteration 10 1 Iteration 11 0 0 0 0 0 0 0 0 Cycle Counter I T H S V N Z C 0 0 0 0 0 0 1 0 Cycles 4 Time 4us R16 0x00 PORTA 0 0 0 0 0 0 0 0 Cycle Counter I T H S V N Z C 0 0 0 0 0 0 1 0 Cycles 4 Time 4us R16 0x00 PORTA 0 0 0 0 0 0 0 0 Cycle Counter I T H S V N Z C 0 0 0 0 0 0 1 0 Cycles 4 Time 4us R16 0x00 PORTA 0 0 0 0 0 0 0 0 Cycle Counter I T H S V N Z C 0 0 0 0 0 0 1 0 Cycles 4 PORTA Iteration 12 Iteration 13 Iteration 14 Iteration 15 Time 4us R16 0x00 PORTA 0 0 0 0 0 0 0 0 Cycle Counter I T H S V N Z C 0 0 0 0 0 0 1 0 Cycles 4 Time 4us R16 0x00 PORTA 0 0 0 0 0 0 0 0 Cycle Counter I T H S V N Z C 0 0 0 0 0 0 1 0 Cycles 4 Time 4us R16 0x00 PORTA 0 0 0 0 0 0 0 0 Cycle Counter I T H S V N Z C 0 0 0 0 0 0 1 0 Cycles 4 Time 4us R16 0x00 PORTA 0 0 0 0 0 0 0 0 I T H S V N Z C Iteration 16 Iteration 17 Iteration 18 Iteration 19 Cycle Counter 0 0 0 0 0 0 1 0 Cycles 4 Time 4us R16 0x00 PORTA 0 0 0 0 0 0 0 0 Cycle Counter I T H S V N Z C 0 0 0 0 0 0 1 0 Cycles 4 Time 4us R16 0x00 PORTA 0 0 0 0 0 0 0 0 Iteration 20 TASK 2 Upload the hex file to microcontroller with updated value of R21 as suggested in Section 5.1 Task2. Observe changes and write them in submission. Time any two reasonable LEDs from task1 and task2. Submit these readings and defend your observations through them. (Due to hardware knowledge limitations , this was performed on Proteus)