UPC EETAC Bachelor's Degree in Telecommunications Systems and in Network Engineering EEL

Chapter 3 problems

      - D3.1 -

CD player buttons

Problems

 

D3.2


1. Specifications

Design the interface for a portable CD player using a PIC18F4520 microcontroller as shown in Fig. 1.

CD player

Fig. 1. CD player application and its symbol. Quartz crystal oscillator frequency is 8 MHz.

Design phase #1: some questions to kick off the project and organise it as a FSM in four sections:

- Draw and explain the hardware-software diagram if we propose the FSM state diagram in Fig. 2 for running the application. Explain the difference between variables and flag variables.

State diagram

Fig. 2. CD player FSM state diagram.

In Fig. 3 there is an example of hardware-software diagram.

hardware-software

Fig. 3. Hardware-software diagram.

- Explain how to poll (read) the switch Open (Op) in read_inputs() connected to RC4 using bitwise operations. Explain how to measure how many times per second is this switch read.

- The CD motor is connected at pin RB6. The pause LED is connected at pin RA2. Explain how to drive these outputs in write_outputs().

- Explain the external interrupt mechanism for connecting Play/pause button at RB1/INT1 and Stop button at RB2/INT2 pin. Explain the general software flowchart for this application and how the ISR() is used.

- Explain how to configure port pins and interrupts in init_system().

- Draw the state_logic() truth table and its equivalent flowchart ready for translation to C language.

 


Design phase #2: an LCD will indicate ASCII messages "PLAY", "STOP", etc. 

- Explain how to connect and program the LCD display to show ASCII messages on the screen.

- Explain new LCD instructions and where they are located in the program flow.

 


Design phase #3: using internal peripherals TMR0 or TMR2

- Configure and program TMR0 represented in Fig. 4 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.

TMR0

Fig. 4. TMR0 architecture for 8-bit mode.

In Fig 5 there are some ideas on how to use and configure TMR0.

Using TMR0
Waveforms

Fig. 5. Configuring TMR0 for geneating a 2.5 Hz waveform (timing period TP = 200 ms).