The customer wants to realize the below functions using TAS5558:
(1) When there is music to play, enable corresponding PWM channels.
(2) When there is no music to play, disable corresponding PWM channels to save power consumption.
The detailed configuration for PWM output is illustrated as below:
(1) DATA1 --> PWM1 & PWM2
(2) DATA2 --> PWM3 & PWM4
(3) DATA3 --> PWM7 & PWM8
That is to say, if there is no output for DATA1, they want to disable PWM1 & PWM2. And if there is output for DATA1, they want to enable PWM1 & PWM2 again.
Below is the code (a function, programmed by C language). They find if they use only register 0x27, they could not shutdown corresponding PWM channels. They have also tried using register 0x03 to shut down all channels first and using register 0x27 to open corresponding channels, but failed again.
The related register must be configured at initialization stage?
Could you please help with that?
void Set_Channel_Enable(Libre_MarkCode_typedef mark, unsigned char enable)
{
static uint8_t enable_state[2]={0xff,0xff};
unsigned char write_byte;
const AmpAddr_SubStruct_Typedef* addr;
if(mark>=MarkCode_LibreA)
{
addr=&AmpAddr.LibreList[mark-1];
write_byte=enable_state[(mark>=MarkCode_LibreD)?1:0];
if(((write_byte&addr->MuteMsk_L)==0)!=(enable!=0))
{
if(enable)write_byte&=~(addr->MuteMsk_L|addr->MuteMsk_R);
else write_byte|=(addr->MuteMsk_L|addr->MuteMsk_R);
AMP_I2C_Write_Byte(addr->Dev,0x03,0xB0);
//DelayMs(2);
AMP_I2C_Write_Byte(addr->Dev,0x27,write_byte);
//DelayMs(2);
//AMP_I2C_Write_Byte(addr->Dev,0x03,0xA0);
enable_state[(mark>=MarkCode_LibreD)?1:0]=write_byte;
#if _DEBUG_PRI
ClassDebugDrv.MyPrintf("CH[%d] enable sta:[%d]\r\n",mark,enable);
#endif
}
}
}