东芝TC9459F-音量控制芯片.pdf (416.1 KB)
This is the datasheet of the TC9459F IC chips, it is a digital volume control IC
But I can't control it with Arduino UNO.
This is my testing code:
#include <SPI.h>
/*
STB(12)->Arduino(10)
DATA(11)->Arduino(11)
SCK(10)->Arduino(13)
*/
#define CSPin_L 2
#define CSPin_R 3
byte L = B01001100;
byte R = B01010000;
byte LD = B10110000;
//byte CS = B0001;
int inputNum = 50;
void setup() {
pinMode(CSPin_L, OUTPUT);
pinMode(CSPin_R, OUTPUT);
digitalWrite(CSPin_L, HIGH);
digitalWrite(CSPin_R, HIGH);
digitalWrite(SS,HIGH);
// initialize SPI:
SPI.begin();
SPI.beginTransaction(SPISettings(500000, LSBFIRST, SPI_MODE0));
//for debug and demostration
Serial.begin(9600);
Serial.setTimeout(5);
delay(1000);
}
void loop() {
// Flush the input buffer
//while (Serial.available())
//Serial.read();
//while (Serial.available())
//{
// inputNum = Serial.parseInt();
// Serial.print("input = ");
// Serial.println(inputNum);
//}
TC9459F_Write(inputNum, inputNum, LD);
//for(int i=0;i<90;i++)
//{
// TC9459F_Write(i, i, LD);
//}
//for(int i=90;i>=0;i--)
//{
// TC9459F_Write(i, i, LD);
//}
//delay(1000);
}
void TC9459F_Write(uint8_t LeftVolume, uint8_t RightVolume, uint8_t Loundness)
{
// take the CS pin low to select the chip:
digitalWrite(SS, LOW);
digitalWrite(CSPin_L, LOW);
//delay(100);
// send in the value via SPI:
SPI.transfer(LeftVolume);
SPI.transfer(RightVolume);
SPI.transfer(Loundness);
//SPI.transfer(CS);
//delay(100);
// take the CS pin high to de-select the chip:
digitalWrite(SS, HIGH);
digitalWrite(CSPin_L, HIGH);
}