The University of NottinghamNingbo, China Department of Electrical and Electronics Engineering Embedded Computing CW3
Coursework Title: Develop a main program and a subroutine using PIC18F assembly language
Coursework Description:
In this coursework, students will write a main program and a subroutine in PIC18F assembly language. Students will learn how to assemble and debug the main program and the subroutine using Microchips MBLAB assemblerdebugger. Students will demonstrate using the MPLAB how the hardware stack pointer STKPTR changes with the execution of the PIC18F CALL and RETURN instructions. The skill of how to use the register indirect addressing mode to access the data memory will also be developed.
Coursework Details:
It is desired to write a subroutine in PIC18F assembly language to compute the summation and average of a number of unsigned numbers stored in the memory. Assuming that Xis are 8bit unsigned numbers stored in consecutive locations in the data memory starting at address 50H, as shown in Fig. 1. Using an Indirect Addressing Mode, you will need to use a pointer to point at the byte to be added to the sum each time.
50H 0FH 21H 69H
0AH 20H 00H 07H 1AH
Fig. 1 The list of 8 bytes stored in the data memory.
The main program is required to be started at address 50H. The main program will be used to do the following:
Perform all the initialization.
Store the 8 bytes at the data memory as indicated by Fig. 1.
Calling a subroutine to perform and update the summation.
Calculating the average Z8 of the 8 unsigned numbers.
A subroutine written starting at address 100H should be developed to mainly calculate the sum Z of the 8 bytes.
In this coursework, the remainder out of computing the average can be discarded.
No hardware implementation is required to complete this coursework. Youll only need to use Microchips MPLAB assemblerDebugger.
The University of NottinghamNingbo, China Department of Electrical and Electronics Engineering Embedded Computing CW3
Coursework Objectives:
By the end of this coursework, students will:
1. Master PIC18F Assembly: Develop proficiency in writing main programs and subroutines in the PIC18F assembly language, equipping you with a fundamental skill set in microcontroller programming.
2. Utilize Microchips MPLAB: Gain handson experience in utilizing Microchips powerful MPLAB assemblerdebugger, enabling you to assemble and debug programs efficiently.
3. Explore Hardware Stack Manipulation: Investigate the dynamic behaviour of the hardware stack pointer STKPTR through the execution of PIC18F CALL and RETURN instructions, providing you with a deep understanding of how these instructions impact program flow.
4. Harness Register Indirect Addressing: Cultivate the skill of employing register indirect addressing mode to access data memory, enhancing your ability to manipulate data effectively within the microcontroller.
The submitted report should include the following:
A flowchart proposing the developed solution.
An assembly code interpreting the proposed flowchart.
Comprehensive comments to the assembly interactions.
A demonstration using the MPLAB of the important SFRs and where necessary program
and data memory.
A demonstration using the MPLAB of how the hardware stack pointer STKPTR changes
with the execution of the PIC18F CALL and RETURN instructions.
Any submission which contains the code only without useful comments, flowcharts, demonstration will receive a mark of zero.
You should aim to complete and submit your report by Monday 11 Nov 2024 at 4 pm. Only an electronic copy of the report and the project files on Moodle will be accepted.
The coursework counts for 10 of the module mark.