I'm trying to read the calibration values from the DAQCard 6036E EEPROM on a WinCE 4.1 device.
I have worked with source code posted in "Reading/Writing to EEPROM & CalDac's" (included below) but it it returns zeros. I get the same result when trying the same code on a AI-16XE-50 card.
Any help would be appreciated,
Andreas
**********************
u8 thisbit;
u16 writevalue;
int index;
//Bar1 = bus->createAddressSpace(kPCI_BAR1);
//board = new tESeries(Bar1);
// Instruction: Single Read EEPROM: 0x03
// Address: 508 (0x1FC), factory year calibration
// Because adress is greater then 0xFF use 0x08 as a modifier of the instruction byte
// Upper byte is command plus address modifier, lower byte is lowest 8-bits of address
// EEPROM bit stream to write: 0000 1011 1111 1100
// writevalue = 0x0bfc; // Address: 508 - year factory calibration
// writevalue = 0x0bfb; // Address: 507 - month factory calibration
// writevalue = 0x0bfa; // Address: 506 - day factory calibration
// writevalue = 0x0bff; // Address: 511 - LSB board code
// writevalue = 0x0bfe; // Address: 510 - board revision
// writevalue = 0x0bfd; // Address: 509 - board subrevision
// writevalue = 0x0bda; // Address: 474 - MSB board code for some cards
// Serial Register
// 0x1 - clock
// 0x2 - data
// 0x4 - chip select - enable EEPROM communciation
// double write all communication to the serial interface/EEPROM
int address = 508; // year factory calibration
if (address > 0xff)
writevalue = 0x0b00 + (address & 0xff);
else
writevalue = 0x0300 + (address & 0xff);
// 0x4 - chip select - enable EEPROM communciation
board->SerialCommandRegister.writeRegister(0x00);
board->SerialCommandRegister.writeRegister(0x00);
board->SerialCommandRegister.writeRegister(0x04);
board->SerialCommandRegister.writeRegister(0x04);
// SerData = address LOC (469,467, 465, 463) to access on EEPROM.
// writevalue = modified address location to access.
for (index = 15; index >= 0; index--)
{// 0
thisbit = ((writevalue >> index) & 0x01) * 0x02;
board->SerialCommandRegister.writeRegister(0x04 + thisbit); // set data bit
board->SerialCommandRegister.writeRegister(0x04 + thisbit);
board->SerialCommandRegister.writeRegister(0x04 + thisbit + 0x1); // set data bit and clock
board->SerialCommandRegister.writeRegister(0x04 + thisbit + 0x1);
board->SerialCommandRegister.writeRegister(0x04);
board->SerialCommandRegister.writeRegister(0x04);
}
int myvalue = 0;
// read back PROMOUT (D7-D0) 8-bit result.
for (index = 7; index >= 0; index--)
{
// read bit
board->SerialCommandRegister.writeRegister(0x04); // set clock low
board->SerialCommandRegister.writeRegister(0x04);
board->SerialCommandRegister.writeRegister(0x04 + 0x1); // set clock high
board->SerialCommandRegister.writeRegister(0x04 + 0x1);
thisbit = board->SerialStatus.readEEPROMOut(); // read data bit
thisbit &= 0x1;
myvalue |= thisbit << index;
printf("thisbit[%d] = %d\n",index,thisbit);
}
printf("eeprom value = %d\n",myvalue);
}"