The practicum will be held in the Micro Lab (Simrall 329), November 18-21, 2024, during your registered lab section.
Distance students will take the practicum via Microsoft Teams video chat during one of the lab sections.
The practicum will cover: GPIO, watchdog timer, interrupt, and timer (i.e. Labs 6-8).
There will be no coverage of EEPROM, SPI, I2C or ADC/DAC.
Feel free to remove your EEPROM, and all associated wiring from your board before you arrive.
At the beginning of the practicum, you will be given a sheet of paper with three tasks on it.
When you complete a task, raise your hand, and the TAs will come over to check you off by initialing your paper and marking the time of completion.
At the end of the practicum, submit your source code and screenshot of output (BullyCPP and/or scope waveform) for each task, and turn in your paper.
Without advance permission from your professor, you will not be allowed to take the practicum at a different time. If you do not show up for the practicum, you will receive a grade of zero.
Per MSU Academic Operating Policy 10.08, you MUST turn your cell phone off – not on vibrate, but completely off. Absolutely NO cheating is allowed. If you are caught in the attempt of, the act of, or the past action of academic dishonesty, you will receive the maximum punishment allowed by University policy. Specifically, you may not share or discuss the questions or your solutions with any MSU student.
You must use your own board (with your Net ID / name written on it in permanent marker).
You should bring your board already wired up, your parts kit, wires, tools, and multimeter. If you need any of the following parts during the practicum, raise your hand and one will be provided free of charge by the TA: resistor, capacitor, fuse, voltage regulator, LED, button, switch, potentiometer. (In-person students only.)
At the end of the practicum, for each completed task, submit a screenshot of your console output and/or scope waveform for each task, and each of your source code files. Submit on Canvas to the Assignment "Lab Test I (Practicum I)". Name your files practicum1.c, practicum2.c, and practicum3.c. Put your name on each. You won't be scored on the quality of your code or comments. Hand in your paper. Submit code, outputs, and paper before time expires and before leaving the room, or you will receive a grade of zero.
There is no partial credit for a task - it is either 33% or 0%. You get 1% free. Thus there are 5 possible grades: 100% (checked off for 3 tasks), 67% (checked off for 2 tasks), 34% (checked off for 1 task), 1% (attended practicum, checked off for 0 tasks), 0% (did not take practicum, didn't turn in paper/output/source code, bit proctor, etc.)
The TAs can answer questions about the interpretation of problems ("So is it supposed to blink when we press the button or when we press it and release it?") or definition of terms ("Does 'press a key' mean a key on my computer?"). They cannot answer questions about how to accomplish a task, debug your code, operate the scope, troubleshoot your board, or fix your computer.
The practicum is open everything, except your neighbor. You may:
look at the lecture notes or books
search the web
use generative AI to write your code
use old labs, pic24_code_examples, lab9, etc as a starting point
write your own code in advance
You may not:
talk to other students in the room
communicate with anyone outside the room via email, text, chat app, messenger pigeon, etc
post to websites seeking assistance
bring in code written for you by somebody else
discuss the questions/answers with other students
As the lab will be in use, there will be no checkoffs or TA assistance during lab time the week of the practicum.
You can do the tasks in any order. Raise your hand when you have completed a task.
Start by opening an MPLAB project that seems like a good starting point for the task you have to perform.
Right click the project and select Set as Main Project.
Build the project, upload it to your board and verify that it is working.
Create a new C file in the same directory as the existing C files for that project:
Either "C Source File..." or "mainXC16.c..." is fine. If neither shows up in your menu, choose "Other..." and select one of those two.
Copy the contents of the old C file into the new file, completely overwriting its contents (Old file: Ctrl-A, Ctrl-C > New file: Ctrl-A, Ctrl-V).
Right click the old C file and choose Exclude from Current Configuration
If you started with ledsw1, and named your file practicum1.c, you should have something that looks like this:
Build the project again and upload to your board to test it. It should work the same as before.
Close the old C file so you don't accidentally write code in there.
For each task, repeat this process anew. DON'T OVERWRITE THE SAME C FILE THREE TIMES.
Open all projects from inside a subfolder of C:\ece3724\pic24_code_examples, not, for example, by copying a project into a folder like C:\Users\Bob Student\Documents and Settings\Micro\Practicum\. The projects require header code that is only in the pic24_code_examples folder.
Do not use OneDrive.
You should have proficiency in the following skills:
Make a state machine
Output text to BullyCPP
Read characters input to BullyCPP (this is done in reset.c from Lab 6 (chap08) but also lab9.c)
Output different-shaped square waves to the scope
Connect an LED, switch, or button to the PIC
Turn an LED on and off
Blink an LED at different rates
Take input from a pushbutton or switch
Write C code to do basic arithmetic and counting
If you have a sudden and inexplicable failure e.g. a program worked fine but now you get software resets or you can't upload programs to your board at all, refer to the walkthrough. Check that you have capacitors on both pin 19 (1 uF, says 105) and pin 20 (10 uf, says 106), and that they are wired as in the photos.
If you use printf, you need to have #include <stdio.h> at the top of the file.
Practice the tasks of the sample practicum below. Don't just run the code in MPLAB and call it good; actually upload each project to your board and check that everything works. Use a scope to check your waveform in sample Task 3. No solutions are provided - ask a TA if you are stuck. The average score of students who completed sample Task 3 before the Spring 2024 practicum was 93.4!
Another good way to practice would be to do other cases from Lab 7. Or you and a buddy could make up your own tasks and race to see who can complete them first!
Fall 2023 mean practicum score: 63.3. Grade distribution: 100 x 20, 67 x 16, 34 x 10, 1 x 5, 0 x 4.
Spring 2024 mean practicum score: 66.6. Grade distribution: 100 x 20, 67 x 55, 34 x 11, 1 x 4, 0 x 5.
Write code that reads a pushbutton – for each press and release of the button, the code should print the message "Button pressed and released: n" where 'n' is the count of press/release actions since the last processor reset. Sample output is shown below for three presses/releases of the button. You can use any pin you wish on the PIC24 for the pushbutton.
Button pressed and released: 1
Button pressed and released: 2
Button pressed and released: 3
Write code that reads a number from the keyboard and blinks an LED five times at one of three different rates (slow, fast, fastest) depending on the number entered. You choose the meanings of slow, fast, fastest in terms of blink speed, but they should be visibly different. You can use software delays for blink speeds. Sample output:
Enter a number (1: slow, 2: fast, 3: fastest): 1
Blinking slowly.
Enter a number (1: slow, 2: fast, 3: fastest): 2
Blinking fast
Enter a number (1: slow, 2: fast, 3: fastest): 3
Blinking fastest
Write code that generates exactly 10 cycles of a 5 KHz square wave from an output pin of your choosing when a character is entered on the keyboard. You must use a timer for accurate timing and you must demonstrate your waveform to the TA using the VirtualBench scope. You need to be within ±5% of the target frequency (4750 Hz to 5250 Hz). You CANNOT use software delay macros in your code – you must use a hardware timer approach in generating these waveforms (the TA will ask to see your code to verify this). There are multiple methods for accomplishing this task. Sample BullyCPP output:
Press any key:
10 cycles generated!
Press any key:
10 cycles generated!
Press any key:
10 cycles generated!
These test problems are similar to practicum problems, though a bit simpler and some of the supporting code is given, since you wouldn't have the same amount of time or resources on an exam. You should be able to accomplish them merely from the description below:
Summer 2020, Exam 3, P2 - Create a state machine that turns an LED on when a pushbutton is pressed, then turns it off on the next press. After 101 presses, the LED stays on and never turns off.
Summer 2020, Exam 3, P3 - Use the timer 3 interrupt to blink an LED every 20 ms. The LED should be on between 0 and 10 ms, then off from 10 to 20 ms, and so on.