Instantiated an altera_voltage_sensor from the IP library "Basic Functions \ Configuration and Programming" operating with a 10 MHz clock. Generated the BSP and built the Core libraries. I can read and write the CSR. Selected mode 01 for channels 0 through 7 conversion and set the start bit 0 to 1. I read the voltages every 10 seconds. The run bit in the CSR register is 0 as expected, but all voltage registers read zero. Any idea what I am doing wrong?
// Read the CSR register
control_register = Inport32(CHIP_VOLTAGE_CONTROLLER_CSR_BASE);
// Set the start bit high
control_register |= CI_FPGA_VOLTAGE_SENSOR_RUN;
// Start the conversion
void CI_FGPA_Voltage_Sensor_Read_Voltages(float *voltages)
// Read all eight voltages
for (alt_u8 ADC = 0; ADC < 8; ADC++)
// Read the ADC register
ADC_register = Inport32(CHIP_VOLTAGE_SAMPLE_STORE_CSR_BASE + ADC) & 0x3F; // 0000 0000 0011 1111
// Calculate the sensor voltage
voltages[ADC] = ADC_register * CI_FPGA_VOLTAGE_SENSOR_STEP;
// Start the next conversion
When I evaluated the code, could not able to get a clear picture how you are reading the registers, I am keeping the below link for your reference.And code as like this.
I went through the all the reference design files, but was not able to find any source code that configures the voltage sensor or performs the read/ conversion.
From the source code above, the read is performed with a call to IORD_32DIRECT(port, 0); Where port is CHIP_VOLTAGE_SAMPLE_STORE_CSR_BASE, but the read always returns zero.
alt_u32 Inport32(alt_u32 port)
// Read the 32-bit register port