Closed enjoy-digital closed 2 years ago
LMH6518 configuration from official firmware:
// PGA LMH6518
enum ThunderScopeHWStatus thunderscopehw_set_pga(struct ThunderScopeHW* ts, int channel)
{
uint8_t fifo[4];
fifo[0] = 0xFB - channel; // SPI chip enable
fifo[1] = 0;
fifo[2] = 0x04; // ??
int vdiv = ts->channels[channel].vdiv;
if (vdiv > 100) {
// Attenuator relay on, handled by
// thunderscopehw_set_datamover_reg.
vdiv /= 100;
}
switch (vdiv) {
case 100: fifo[3] = 0x0A; break;
case 50: fifo[3] = 0x07; break;
case 20: fifo[3] = 0x03; break;
case 10: fifo[3] = 0x1A; break;
case 5: fifo[3] = 0x17; break;
case 2: fifo[3] = 0x13; break;
case 1: fifo[3] = 0x10; break;
default: return THUNDERSCOPEHW_STATUS_INVALID_VDIV;
}
switch (ts->channels[channel].bw) {
case 20: fifo[3] |= 0x40; break;
case 100: fifo[3] |= 0x80; break;
case 200: fifo[3] |= 0xC0; break;
case 350: /* 0 */ break;
default: return THUNDERSCOPEHW_STATUS_INVALID_BANDWIDTH;
}
return thunderscopehw_fifo_write(ts, fifo, 4);
}
LMH6518 added totest_frontend
with https://github.com/enjoy-digital/thunderscope/commit/e6f17f3e9b3b61dfd3d5bcf4b1612af5dbb11993. SPI/Configuration seems to be done correctly when looking at PGA output with a scope.
Done.
LMH6218 is a Programmable Gain Amplifier, present on each of the 4 channels. IN_P is connected to the Frontend. IN_P is connected to TRIM (https://github.com/enjoy-digital/thunderscope/issues/5). The configuration is done over SPI with common SDIO/SCLK for all chips and separate CSn. Let's first do a simple unit-test over JTAGBone and verify outputs with a scope.