I've been working with getting a AFE5851EVM board connected to custom logic. I have no issues except programming the TGC; I've only tried setting static gain.
I first set the TGC_REGISTER_WREN bit in reg0, then write the coarse gain at 0x9A and fine gain (and STATIC_PGA bit) at 0x99, then clear the TGC_REGISTER_BIT:
//gain is ((-5 to 31.875)+5)*8
void setGain(uint16_t *g)
{
spiWrite(0, 1 << 2);
spiWrite(0x9A, (*g >> 3) & 0x3F);
spiWrite(0x99, (*g & 0x7) | (1 << 3));
spiWrite(0, 0);
}
The output of the AFE always stays at the same magnitude, regardless of what is written here! Any ideas?