This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AFE4490 ambient cancellation current

Other Parts Discussed in Thread: AFE4490

hi sir,

I found that ambient cancellation current setting only affects LED2's result (LED2VAL). when I change AMBDAC[3:0], LED2VAL's DC value changes but LED1VAL's DC value not change anyway. Why ? Registers setting as below:

#define AMBDAC_0uA 0
#define AMBDAC_1uA 1
#define AMBDAC_2uA 2
#define AMBDAC_3uA 3
#define AMBDAC_4uA 4
#define AMBDAC_5uA 5
#define AMBDAC_6uA 6
#define AMBDAC_7uA 7
#define AMBDAC_8uA 8
#define AMBDAC_9uA 9
#define AMBDAC_10uA 10
#define AVE1 0
#define AVE2 1
#define AVE3 2
#define AVE4 3
#define AVE5 4
#define AVE6 5
#define AVE7 6
#define AVE8 7
#define AVE9 8
#define AVE10 9
#define AVE11 10
#define RF_500K 0
#define RF_250K 1
#define RF_100K 2
#define RF_50K 3
#define RF_25K 4
#define RF_10K 5
#define RF_1M 6
#define RF_None 7
#define CF_5p 0
#define CF_10p BIT3
#define CF_15p BIT4
#define CF_25p BIT5
#define CF_50p BIT6
#define CF_150p BIT7
#define CF_250p BIT7+BIT6+BIT5+BIT4+BIT3
#define STG2_EN BITE
#define SEPGAIN_EN BITF
#define STG2GAIN0 0
#define STG2GAIN1 BIT8
#define STG2GAIN2 BIT9
#define STG2GAIN3 BIT9+BIT8
#define STG2GAIN4 BITA
#define TIMEREN BIT8

const uint afeMapping[0x031]={
0x0 , //address
30001, // 1 Start of sample LED2 pulse
39998, // 2 End of sample LED2 pulse

30000, // 3 Start of LED2 pulse
39999, // 4 End of LED2 pulse

1, // 5 Start of sample LED2 ambientter
9998 , // 6 End of sample LED2 ambientter

10001 , // 7 Start of sample LED1 pulse
19998 , // 8 End of sample LED1 pulse

10000 , // 9 Start of LED1 pulse
19999, // 10 End of LED1 pulse

20001 , // 11 Start of sample LED1 ambient pulse
29998, // 12 End of sample LED1 ambient pulse

2 , // 13 Start of convert LED2 pulse
9999 , // 14 End of convert LED2 pulse

10002 , // 15 Start of convert LED2 ambient pulse
19999 , // 16 End of convert LED2 ambient pulse

20002 , // 17 Start of convert LED1 pulse
29999, // 18 End of convert LED1 pulse

30002, // 19 Start of convert LED1 ambient pulse
39999, // 20 End of convert LED1 ambient pulse

0 , // 21 Start of first ADC conversion reset pulse
0 , // 22 End of first ADC conversion ret pulse

10000 , // 23 Start of second ADC conversion reset pulse
10000 , // 24 End of second ADC conversion reset pulse

20000 , // 25 Start of third ADC conversion reset pulse
20000 , // 26 Enf third ADC conversion reset pulse

30000, // 27 Start of fourth ADC conversion reset pulse
30000, // 28 End of fourth ADC conversion reset pulse

40000, // 29 End of pulse repetition period
//////////////////////////////////////////////////////
AVE4+TIMEREN , // 1E Control Register 1
0x0 , // 1F SPARE1 for future use
RF_100K+CF_250p+SEPGAIN_EN, // 20 enable seperate gain mode (for ir LED)
RF_100K+CF_250p+STG2GAIN2+STG2_EN, // 21 TIA_AMB_GAIN register(for red LED)
0x3030 , // 22 LED Control Register
BIT9 , // 23 Control Register 2
0x0 , // 24 SPARE2 for future use
0x0 , // 25 SPARE3 for future use
0x0 , // 26 SPARE4 for future use
0x0 , // 27 RESERVED1 for factory use
0x0 , // 28 RESERVED2 for factory use
0x0 , // 29 Alarm Register
0x0 , // 2A LED2 Digital Sample Value Register
0x0 , // 2B Ambient LED2 Digital Sample Value Register
0x0 , // 2C LED1 Digital Sample Value Register
0x0 , // 2D Ambient LED1 Digital Sample Value Register
0x0 , // 2E LED2-Ambient LED2 Digital Sample Value Register
0x0 , // 2F LED1-Ambient LED1 Digital Sample Value Register
0x0 // 30 Diagnostics Flag Register
};

void Init_AFE()
{
char datH, datL;
int dat, i;
for (i=0; i<sizeof(afeMapping); i++)
{
dat=afeMapping[i];
datH=dat>>8;
datL=dat;
switch (i)
{
case 0x21:
write_afe( i, AMBDAC_4uA, datH, datL ); //cancellation current
break;
case 0x22:
write_afeLEDs();
break;
default:
write_afe( i, 0, datH, datL );
}
}
write_afe(0, 0, 0, BIT0 ); //RESET, SPI read is enabled
}