Untitled
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."); log.Close(); // Close log or necessary file // Calibration Status Read int cal_status = -1; // Initialize to an invalid value //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"); } }
Leave a Comment