What is PFM? PFM is used to vary the frequency of a square wave in proportion to the amplitude of an analog signal. The duty cycle of the modulated signal remains unchanged and it is also known as square-wave FM. PFM can be used to convert between analog signals and digital outputs. See figure 1. PFM Figure 1. PFM signal
Write code to generate a PFM signal output to an output pin and then view it via an oscilloscope. The amplitude of the input signal should be changeable by pressing a button and the button presses should be counted via LEDs connected to the microcontroller.
Specification:
1. When you start the program, nothing happens and all LED off.
2. When button pressed, use a starting frequency of 1kHz (and LED count 1)
3. With every new button pressed, frequency multiplies by 2 (i.e 2kHz, 4Khz, et.c) and the LED counts
accordingly (i.e 2, 3, 4, …,7 and then go back to 0).
4. When the count is 7, it restarts from 0 again (meaning all LEDs are OFF and no signal at the
oscilloscope)
Recommended Steps:
1. Connect the Switch and the 3 LEDs
2. Connect the limiting resistors to the LED and the pull-up resistor to the switch
(The resistor values will be determined in the lab)
3. Write the code to count the button presses (remember to debounce it if necessary)
4. Now generate the Pulses for each count. (Duty cycle is constant at 50% all through)


Step by step
Solved in 2 steps with 4 images









