Thanks, Tom; that almost helped. Now, I can bring the ADC values
for zero voltage input down from 340 to 40, but the Windows test panel
still gets the dead value down to -5. I don't understand how I
can load all CALDAC registers from the EEPROM as instructed and still
get a different result. This is my code so far; please tell me
why my 6034E still behaves differently:
//Calling test function
copyEEPROM(bus);
inline void cycleClock(tESeries *board, const timespec * nap_p)
{
board->SerialCommandRegister.writeSerialClock(
board->SerialCommandRegister.kSerialClockLow); // low clock
clock_nanosleep(CLOCK_MONOTONIC,0,nap_p,NULL);
board->SerialCommandRegister.writeSerialClock(
board->SerialCommandRegister.kSerialClockHigh); // high clock
clock_nanosleep(CLOCK_MONOTONIC,0,nap_p,NULL);
board->SerialCommandRegister.writeSerialClock(
board->SerialCommandRegister.kSerialClockLow); // low clock
clock_nanosleep(CLOCK_MONOTONIC,0,nap_p,NULL);
}
void copyEEPROM(iBus *bus)
{
tAddressSpace Bar1;
tESeries *board;
tSTC *theSTC;
u8 data[4];
Bar1 = bus->createAddressSpace(kPCI_BAR1);
board = new tESeries(Bar1);
theSTC = new tSTC(Bar1);
theSTC->flushBus();
theSTC->reset();
printf("EEPROM\treg\tvalue\tCALDAC reg\n");
readEEPROM(board, data);
printf("\t%d\t%d\t%d\n", 439, data[0], 2);
printf("\t%d\t%d\t%d\n", 440, data[1], 1);
printf("\t%d\t%d\t%d\n", 441, data[2], 11);
printf("\t%d\t%d\t%d\n", 442, data[3], 4);
writeCALDAC(board, data);
delete theSTC;
delete board;
bus->destroyAddressSpace(Bar1);
}
void readEEPROM(tESeries *board, u8 data[4])
{
int i, id;
u8 temp;
u16 command = 0, eeprom_reg = 439;
const timespec nap = {0, 1000};
// create data to send
for (i=0;i<8;i++)
command = (command << 1) +
( (eeprom_reg >> i) & 1 ); // A7:A0
command = (command<<8) +
0xD0;
// A8 = 1
printf("command = %d\n", command);
// read EEPROM registers
board->SerialCommandRegister.setRegister(0);
// clear
softcopy
board->SerialCommandRegister.writeEEPromChipSelect(
board->SerialCommandRegister.kEEPromChipSelectHigh); // enable EEPROM
// shift in address
for (i=0;i<16;i++)
{
board->SerialCommandRegister.writeSerialData((u8)((command >> i) & 1));
cycleClock(board, &nap);
}
// shift out data
for (id=0;id<4;id++)
for (i=0;i<8;i++)
{
board->SerialCommandRegister.writeSerialClock(
board->SerialCommandRegister.kSerialClockLow); //
low clock
clock_nanosleep(CLOCK_MONOTONIC,0,&nap,NULL);
board->SerialCommandRegister.writeSerialClock(
board->SerialCommandRegister.kSerialClockHigh); //
high clock
clock_nanosleep(CLOCK_MONOTONIC,0,&nap,NULL);
temp =
board->SerialStatus.readEEPROMOut();
// get bit 0 from EEPROM out
data[id] =
(data[id] << 1) + temp;
// assemble
data byte
board->SerialCommandRegister.writeSerialClock(
board->SerialCommandRegister.kSerialClockLow); //
low clock
clock_nanosleep(CLOCK_MONOTONIC,0,&nap,NULL);
}
board->SerialCommandRegister.writeEEPromChipSelect(
board->SerialCommandRegister.kEEPromChipSelectLow);
// forget this and you destroy the card
}
void writeCALDAC(tESeries *board, u8 data[4])
{
int i, id;
u16 command;
const timespec nap = {0, 1000};
const u8 address[4] = {2, 1, 11, 4};
board->SerialCommandRegister.setRegister(0);
// clear
softcopy
board->SerialCommandRegister.writeEEPromChipSelect(
board->SerialCommandRegister.kEEPromChipSelectLow);
// forget this and you destroy the card
for (id=0;id<4;id++)
{
command = 0;
for(i=0;i<8;i++)
command = (command << 1) + ((data[id] >> i) & 1);
command = (command << 4) + address[id];
for(i=0;i<12;i++)
{
board->SerialCommandRegister.writeSerialData((u8)((command >>
i) & 1));
clock_nanosleep(CLOCK_MONOTONIC,0,&nap,NULL);
board->SerialCommandRegister.writeSerialClock(
board->SerialCommandRegister.kSerialClockLow); //
low clock
clock_nanosleep(CLOCK_MONOTONIC,0,&nap,NULL);
board->SerialCommandRegister.writeSerialClock(
board->SerialCommandRegister.kSerialClockHigh); //
high clock
clock_nanosleep(CLOCK_MONOTONIC,0,&nap,NULL);
}
board->SerialCommandRegister.writeSerialDacLoadNum(1);
clock_nanosleep(CLOCK_MONOTONIC,0,&nap,NULL);
board->SerialCommandRegister.writeSerialDacLoadNum(0);
clock_nanosleep(CLOCK_MONOTONIC,0,&nap,NULL);
}
board->SerialCommandRegister.writeRegister(0); // low clock
return;
}