Practicum

Updated with Spring 2024 information!

Basics

Rules and Regulations

Practicum Hints

Best way to complete a task:

8. Build the project again and upload to your board. It should work the same as the original project. 

9. Write your code in the new file.

10. For each task, repeat this process anew. DON'T OVERWRITE THE SAME C FILE THREE TIMES.

Other Tips

Sample Practicum

TASK 1

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

Use a printf statement in your C code like the following to print out the number of presses (this assumes that the variable used to count the button press/releases is named u16_count).

printf("Button pressed and released: %d\n ", u16_count);

TASK 2

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

TASK 3

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 from the serial port. You must use a timer for accurate timing and you must demonstrate your waveform to the TA using the VirtualBench (either the scope or the logic analyzer). 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!