Question about SPI control TOSHIBA TC9459F IC?

Hello Guys
I am learning how to control TOHIBA TC9459F IC chip, which is a electronic volume control IC.


This chip using SPI to control

this is my testing code in Arduino

#include <SPI.h>

#define CSPin 2

byte L = B11100100;
byte R = B00011001;
byte LD = B00001101;
//byte CS = B0001;
uint16_t temp = 0;

void setup() {

  pinMode(CSPin, OUTPUT);
  digitalWrite(CSPin,HIGH);
  digitalWrite(SS,HIGH);

  // initialize SPI:
  SPI.begin();
  SPI.beginTransaction(SPISettings(1000000, LSBFIRST, SPI_MODE0));

  //for debug and demostration
  Serial.begin(9600);

  delay(1000);
}

void loop() {

  //for(int i=0;i<=89;i++)
  //{
    TC9459F_Write(L, R, LD);
  //}

  //for(int i=0;i<=89;i++)
  //{
  //  TC9459F_Write(89-i, R, LD);
  //}
  
}

void TC9459F_Write(uint8_t LeftVolume, uint8_t RightVolume, const bool Loundness)
{

  // take the CS pin low to select the chip:

  digitalWrite(SS, 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);
}

I am try to send LeftVolume, RightVolume and LD binary data to TC9459

byte L = B11100100;
byte R = B00011001;
byte LD = B00001101;
//  send in the value via SPI:

  SPI.transfer(LeftVolume);
  SPI.transfer(RightVolume);
  SPI.transfer(Loundness);

and I used Loghic 2 to show the result.

The LeftVolume and RightVolume data are correct, but the LD data is not. what is wrong with it ?

No matter what I sent to LD, it is still b1000 0000
5

Only I sent b00000000, it will b0000 0000
6

could it be

void TC9459F_Write(uint8_t LeftVolume, uint8_t RightVolume, const bool Loundness)

because Loundness is declared as a bool??

Oh yes, thank you very much.

I works now. Thank you very much.
3

东芝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);
}

When I set inputNum to 0

this is what I got from CK(pin 13), DATA(pin 11) and STB(pin 10)

There is no attenuation of the signal.

It is correct.

But when I set inputNum to 50

this is what I got from CK(pin 13), DATA(pin 11) and STB(pin 10)

it is -50dB attenuation according to datasheet

but no attenuation of the output.

What is the problem of the code?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.