Some of the conditions to communicate through the I2C bus are:
- Data validity: The data on the SDA 64 remote controlled Digital Audio Processor line must be stable during the high period of the clock. The high and low states of the data line can change only when the clock signal on the SCL line is low.
- Start and Stop: A start condition is a high-to-low transition of the SDA line while SCL is high. The stop condition is a low-to-high transition of the SDA line while SCL is high.
- Byte format: Every byte transferred on the SDA line must contain eight bits. The most significant bit (MSB) is transferred first.
- Acknowledge: Each byte must be followed by an acknowledgement bit. The acknowledge clock pulse is generated by the master. The transmitter releases the SDA line (high) during the acknowledge clock pulse. The receiver must pull down the SDA line during the acknowledge clock pulse so that it remains low during the high period of this clock pulse.
To program any of the parameters, the following interface protocol is used for sending the data from the microcontroller to TDA7439. The interface protocol comprises:
- A start condition (S)
- A chip address byte containing the TDA7439 address (88H) followed by an acknowledgement bit (ACK)
- A sub-address byte followed by an ACK. The first four bits (LSB) of this byte indicate the function selected (e.g., input select, bass, treble and volume). The fifth bit indicates incremental/ non incremental bus (1/0) and the sixth, seventh and eighth bits are ‘don’t care’ bits.
- A sequence of data followed by an ACK. The data pertains to the value for the selected function.
- A stop condition (P)
In the case of non-incremental bus, the data bytes correspond only to the function selected. If the fifth bit is high, the sub-address is automatically incremented with each data byte. This mode is useful for initialising the device. For actual values of data bytes for each function, refer to the datasheet of TDA7439.
Similar protocol is followed for sending data to/ from the microcontroller to MC24C02 EEPROM by using its chip address as ‘A0H’.
Fig. 3 shows the power supply circuit for the remote controlled digital audio processor. The AC mains is stepped down by transformer X1 to deliver a secondary output of 9V AC at 1A. The transformer output is rectified by full-wave bridge rectifier BR1 and filtered by capacitor C42. Regulators IC8 and IC9 provide regulated 5V and 9V power supplies, respectively. IC10 acts as the variable power supply regulator. It is set to provide 3V regulated supply by adjusting preset VR1. Capacitors C39, C40 and C41 bypass any ripple in the regulated outputs. This supply is not used in the circuit. However, the readers can use the same for powering devices like a Walkman (portable music player).
As capacitors above 10 μF are connected to the outputs of regulator ICs, diodes D3 through D5 provide protection to the regulator ICs, respectively, in case their inputs short to ground. Relay RL1 is normally energised to provide mains to the power amplifier. In standby mode, it is de-energised. Switch S2 is the ‘on’/ ‘off ’ switch.
The software was assembled using Metalink’s ASM51 assembler, which is freely available for download. The source code has been extensively commented for easier understanding. It can be divided into the following segments in the order of listing:
- Variable and constant definitions
- Delay routines
- IR decoding routines
- Keyboard routines
- TDA7439 communication
- MC24C02 communication
- I2C bus routines
- Display routines
- IR and key command processing
- Timer 1 interrupt handler
- Main program
On reset, the microcontroller executes the main program as follows:
- Initialise the microcontroller’s registers and random-access memory (RAM) locations.
- Read Standby and Mute status from the EEPROM and initialise TDA7439 accordingly.
- Read various audio parameters from the EEPROM and initialise the audio processor.
- Initialise the display and LED port.
- Loop infinitely as follows, waiting for events:
Enable the interrupts.
- Check the monitor input for AC power-off. If the power goes off, jump to the power-off sequence routine.
- Else, if a new key is pressed, call the DO_KEY routine to process the key. For this, check whether the NEW_KEY bit is set. This bit is cleared after the command is processed.
- Else, if a new IR command is received, call the DO_COM routine to process the remote command. For this, check whether the NEW_COM (new IR command available) bit is set.
- This bit is cleared after the command is processed.
- Jump to the beginning of the loop.