Das Ansteuern des TDA7318 ist relativ einfach - wenn man von dem Bitgeschubse absieht. Um an dem IC eine Einstellung zu machen, genügt für jede Funktion ein einziges Byte. Hier der avr-gcc Quellcode für einen AVR Mikrocontroller:
tda7318.h:
#ifndef __I2C__TDA7318_H__INCLUDED__ #define __I2C__TDA7318_H__INCLUDED__ #include <stdint.h> //////////////////////////////// // Configuration #ifndef I2C_TDA7318_ADDRESS #define I2C_TDA7318_ADDRESS 0x44 ///< The chip's address. (Without r/w bit) #endif //////////////////////////////// #define I2C_TDA7318_SPEAKER_LF 0x00 ///< Left Front. #define I2C_TDA7318_SPEAKER_RF 0x01 ///< Right Front. #define I2C_TDA7318_SPEAKER_LR 0x02 ///< Left Rear. (Just a copy of Left Front) #define I2C_TDA7318_SPEAKER_RR 0x03 ///< Right Rear. (Just a copy of Right Front) #define I2C_TDA7318_TONE_BASS 0x00 ///< Bass Control #define I2C_TDA7318_TONE_TREBLE 0x01 ///< Treble Control /** \brief Volume Control * * Sets the volume from 0.00dB to -78.75dB in 1.25dB steps. * Only the lower 6 bits are used. * * @param volume The volume. */ void i2c_tda7318_volume_write_begin( uint8_t volume ); /** \brief Speaker Attenuators * * Speaker attenuation from 0.00dB to 38.75dB in 1.25dB steps. (38.75dB => muted) * Only the lower 5 bits are used. * To select the speaker, choose one of: I2C_TDA7318_SPEAKER_LF, I2C_TDA7318_SPEAKER_RF, I2C_TDA7318_SPEAKER_LR, I2C_TDA7318_SPEAKER_RR or 0,1,2,3. * * @param speaker Which speaker to set. * @param attenuation Attenuation of selected speaker. */ void i2c_tda7318_attenuation_write_begin( uint8_t speaker, uint8_t attenuation ); /** \brief Audio Switch * * Selects a stereo input and gain from 1 of 4 sources. (only the lower 2 bits are used) * Input gain from 18.75dB to 0.00dB in 6.25dB steps. (only the lower 2 bits are used) * * @param input Which stereo input to choose: 0, 1, 2, 3 * @param gain Input gain. */ void i2c_tda7318_switch_write_begin( uint8_t input, uint8_t gain ); /** \brief Tone Control * * Sets the Tone from -14dB to 14dB in 2dB steps. * Only the lower 4 bits are used. * * @param tone One of: I2C_TDA7318_TONE_BASS, I2C_TDA7318_TONE_TREBLE or 0, 1. * @param volume The volume. */ void i2c_tda7318_tone_write_begin( uint8_t tone, uint8_t volume ); #endif
tda7318.c:
#include "i2c.h" #include "tda7318.h" void i2c_tda7318_volume_write_begin( uint8_t volume ) { volume &= 0x3f; // clear the first 2 bits -> correct opcode for volume // 0 0 v v v v v v i2c_writebyte_begin( I2C_TDA7318_ADDRESS << 1, volume ); } void i2c_tda7318_attenuation_write_begin( uint8_t speaker, uint8_t attenuation ) { speaker &= 0x03; // maximum of 4 speakers -> 2 bits speaker <<= 5; attenuation &= 0x1f; // only 5 bits used for attenuation // 1 s s a a a a a i2c_writebyte_begin( I2C_TDA7318_ADDRESS << 1, 0x80 | speaker | attenuation ); } void i2c_tda7318_switch_write_begin( uint8_t input, uint8_t gain ) { input &= 0x03; // there are only 4 sources -> 2 bits needed gain &= 0x03; // 4 steps -> 2 bits gain <<= 3; // now in the correct format // 0 1 0 g g 0 i i i2c_writebyte_begin( I2C_TDA7318_ADDRESS << 1, 0x40 | input | gain ); } void i2c_tda7318_tone_write_begin( uint8_t tone, uint8_t volume ) { tone &= 0x01; // only bass and treble -> 1 bit needed tone <<= 4; volume &= 0x0f; // 4 bits for volume // 0 1 1 t v v v v i2c_writebyte_begin( I2C_TDA7318_ADDRESS << 1, 0x60 | tone | volume ); }
Die Einzigen externen Funktionen die noch benötigt werden sind:
void i2c_writebyte_begin( uint8_t address, uint8_t data );um ein einzelnes Byte an die gegebene I²C Adresse zu schicken, und eventuell
uint8_t i2c_write_end( void );damit der Schreibvorgang abgeschlossen wird.
Letztendlich sollte man zum Beispiel mit
i2c_tda7318_volume_write_begin( -48 ); i2c_write_end();Die Lautstärke verändern können.
Lassen Sie mich sagen, ich spreche kein Deutsch zu starten, bin ich mit Google Translate auf diesen Beitrag vom Englischen ins Deutsche übersetzen. Ich bin neu bei Elektronik, und ich bin um Hilfe, um Ihre TDA7318 Vorverstärker neu suchen. Ich habe einige Erfahrung in der Programmierung, und ich kann die grundlegenden Schaltungen folgen. Ich habe habe viele TDA7313/TDA7318 Projekte online mit Schaltplänen gefunden, aber keiner von ihnen allen geben Ihnen Informationen wie zB Stress, Anspannung Ernährung und Toleranz. Ich brauche, um die Spannung, Typ (Aluminium, Keramik, Film), Betriebstemperatur und Toleranz kennen. Genau, wenn Sie mir die genaue Teilenummer, konnte ich sehen, alle diese Informationen. Vielen Dank im Voraus.
AntwortenLöschenIch habe die Schaltung für den TDA7318 praktisch genau so aufgebaut wie im Datenblatt.
AntwortenLöschenAlle dipolaren Kondensatoren sind normale Aluminium-Elkos. Die anderen sind Folienkondensatoren. Toleranzen spielen keine allzu große Rolle. Wenn die Werte so sind wie im Datenblatt, dürfte es keine Probleme geben.
Der TDA selbst wird von einem 9V Spannungsregler gespeist - zum Beispiel ein 78S09.
---
I built the circuit for the TDA7318 almost exactly like the examples in the datasheet.
All polarized capacitors are normal aluminum electrolytic ones. All others are foil capacitors. Tolerances don't really matter that much. As long as the values are those you see in the datasheet, you should have no problems.
The TDA itself is fed through a 9V voltage regulator e.g. 78S09.