Chapter 3 problems |
- D3.1 - |
CD-MP3 player buttons (µC - C) |
|
1. Specifications
Design the interface for a portable CD-MP3 player using a PIC18F46K22 microcontroller as shown in Fig. 1.
The same project designed using hardware is stated in D2.1.
![]() |
Fig. 1. CD-MP3 player application and its symbol. |
2. Planning
Let us build the product organising several design phases, and several steps within each phase.
Some questions to kick off the project and organise it as a FSM in four sections:
Draw an example of timing diagram.
Project location:
C:\CSD\P10\MP3_player\(files)
Copy and adapt a circuit from a convenient tutorial project and name it "MP3_player.pdsprj". Assign pins to inputs and outputs accordingly to one of the following options (your instructor will tell you which):
Pin assignment option #1:
Pp --> RB1; Sp --> RB0; Op --> RC4
L --> RA2; M --> RB5
CLK --> RB2
Pin assignment option #2:
Pp --> RB2; Sp --> RB1; Op --> RB7
L --> RA3; M --> RC5
CLK --> RB0
Pin assignment option #3:
Pp --> RB0; Sp --> RB2; Op --> RB5
L --> RC2; M --> RA1
CLK --> RB1
Draw the hardware schematic. Buttons and switches, resistors, inputs, outputs, reset circuit MCLR_L and quartz crystal oscillator of 16 MHz. Explain how to configure inputs and outputs in init_system(). Open door switch is polled at the external CLK oscillator frequency of 250 Hz.
Draw the flowchart of the general program organisation.
Draw the hardware/software diagram indicating the required RAM variables and their type. Explain the difference between variables and flag variables.
![]() |
Fig. 2. Example of a section of the hardware-software diagram sketch. |
Infer the state diagram governing the machine.
![]() |
Fig. 2. CD player FSM state diagram. |
Explain how to poll (read) the switch Open (Op) in read_inputs() using bitwise operations.
Explain how to drive output pins in write_outputs().
Explain the external interrupt mechanism for connecting the Play/pause button and the Stop button. Explain how the ISR() is used.
Draw the state_logic() truth table and its equivalent flowchart ready for translation to C language. What is the difference in the flowchart of polling continuously the switch Open and polling it only when the external CLK is detected?
Draw the output_logic() truth table and its equivalent flowchart ready for translation to C language.
Develop and test (debugging) the project capturing the hardware circuit in Proteus and writing the C source code.
Note: Step-by-step tactical approach for developing and testing the project: Read one input at a time and run to check that the voltage value is correctly captured as a valid digital value in RAM memory. Write one output at a time and run to check that your code is correct to light the LED connected at the output pin. |
Project location:
C:/CSD/P11/MP3_player_LCD/files)
Explain how to connect and program the LCD display to show ASCII messages on the screen such: "PLAY", "STOP", etc.
Connect the battery charge sensor and explain and compile the new LCD instructions and where they are located in the program flow. Visualise the battery level value as a percentage number.
Use the TMR2 to replace external CLK interrupts.
Project location:
C:/CSD/P12/MP3_player_LCD_TMR2/files)
Configure and program TMR2 to generate a squared 2.5 Hz signal so the LED will be blinking intermittently when at Stopped state. Explain whether new states are required.
Optional: Measuring battery levels is a must for all portable electronic equipment. Battery charge is acquired usually using analogue to digital converters and voltage sensors. Find chips and schematics to monitor battery levels. Use one analogue channel of the embedded microcontroller A/D for this purpose to replace the digital charge simulator in this application.