Untitled
unknown
plain_text
10 months ago
3.0 kB
4
Indexable
private void ADCEnable_Click(object sender, EventArgs e)
{
openfile(); // Open log or necessary file
string text = "*****ADC_Test******";
log.WriteLine(text); // Log the ADC test start
// Enable the PAT Select registers before enabling the ADC Calibration (new SPI Register Set)
int PAT_SELECT = 0x01;
// Write to FPGA Registers
FPGACommunicationHandler.FPGAInstance.WriteToFPGARegister(TestBuildConstants.BASE_ADDRESS, OPERATINGMODE, PAT_SELECT);
// Default value of CAL_EN register (0x01 - enabled) (new SPI Register)
int CAL_EN = 0x01;
// Enable calibration by setting CAL_EN bit high (1)
ADCTestResult.Text = "Calibration Enabled";
log.WriteLine("Calibration Enabled: Address = 0x061, Value = 0x01");
// Write to the FPGA register to enable calibration
FPGACommunicationHandler.FPGAInstance.WriteToFPGARegister(TestBuildConstants.BASE_ADDRESS, OPERATINGMODE, CAL_EN);
// Display status message indicating that calibration has been enabled
CalibrationStatusResult.Text = "Calibration has been successfully enabled";
log.WriteLine("Calibration process completed successfully.");
// Perform a single 32-bit write operation to 0x180h for ADC configuration
int ADC_CONFIGURATION = 0xFFFFFFFF; // Example value, update as needed
// Increment or Decrement the ADC configuration value
bool increment = true; // Example: Set this based on your requirement
int adcConfigChange = 0x00000001; // Change value per increment or decrement operation
if (increment)
{
ADC_CONFIGURATION += adcConfigChange; // Increment ADC config value
log.WriteLine("ADC configuration incremented.");
}
else
{
ADC_CONFIGURATION -= adcConfigChange; // Decrement ADC config value
log.WriteLine("ADC configuration decremented.");
}
// Write updated ADC configuration to FPGA
FPGACommunicationHandler.FPGAInstance.WriteToFPGARegister(0x180, 0, ADC_CONFIGURATION);
log.WriteLine($"32-bit ADC configuration write completed: Address = 0x180, Value = {ADC_CONFIGURATION:X8}");
// Calibration Status Read
int cal_status = -1; // Initialize to an invalid value
// Uncomment the following line to read the calibration status from the FPGA
// FPGACommunicationHandler.FPGAInstance.ReadFromFPGARegister(TestBuildConstants.BASE_ADDRESS, TestBuildConstants, ref cal_status);
// Check if the read operation was successful
bool readSuccess = (cal_status != -1); // Assuming -1 is not a valid status
if (readSuccess)
{
CalibrationStatusResult.Text = "Success";
log.WriteLine($"Calibration Status Read Successfully: Address = {Cal_Status_Address}, Value = {cal_status}");
}
else
{
CalibrationStatusResult.Text = "Failure ";
log.WriteLine("Failed to Read Calibration Status");
}
log.Close(); // Close log or necessary file
}
Editor is loading...
Leave a Comment