The ADC uses the Core clock which we have set to 120meg, from that the ADC MCAL has the clock prescaler and the calibration prescaler. The data sheet specifies a calibration frequency range (40 to 60) and a conversion frequency range (80 to 120) for the highest conversion speeds in Table 317. Digging into the calibration code I noticed two things – one function calls out that the conversion clock must not be faster that 80 and the calibration not faster than 40.
The second thing I noticed was that the calibration does not successfully complete, and I do not know why. The Failure bit is set after line 3356 in Adc_Sar_Ip.c, shown below
The values that the ADC puts into the result buffer are wrong by a fair amount, before I can even touch them with my handwritten code, it almost looks like its using a 5V reference, but we only have 3.3 on the board so that’s baffling.
I am attempting to run the calibration multiple times, but it fails each time. Why is it failing and how can I fix it?
The function that calls out frequencies
The calibration failure point - after which failure bit is set
Hardware Configuration
Calibration is successful on custom board with a lower noise voltage source and additional caps on the VREFH line as found on the dev kit eval board
Seems that you are refer the "Table 317. Clock configuration for highest conversion speeds" of S32K3xx_RM_Rev7:
For example, the ADC calibration frequency of S32K312 devices should be 40-60MHz. From Table 317, the calibration frequency of 40MHz seems to apply to all rows. Maybe that's why Adc_Sar_Ip_DoCalibration configures the 40MHz calibration frequency.
Please check whether the reason for calibration failure is calibration timeout(ADC_SAR_IP_STATUS_TIMEOUT
If so, this may caused by the default Adc Timeout Method type for calibration is OSIF_COUNTER_DUMMY which is not accurate enough.
Please try to select OSIF_COUNTER_SYSTEM and set the corresponding Adc Timeout value by refer to:
I didn't check the configuration of each page carefully. Have you tested Adc_example_S32K312 in RTD?
Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hi Robin,
The reason for failure is not timeout. The IF statement just below the one you have highlighted which checks the Failure bit ADC_SAR_IP_CALIBSTREG_TEST_FAIL_MASK is where the failure occurs.
The RTD I have been working with, Patch 4 did not contain Adc_example_S32K312. I have update to use Patch 20 RTD which also does not seem to contain that example. I have been referring to a K344 example when setting other MCALs up and modifying based on the data sheet and reference manuals where needed.
Sorry I haven't seen S32K312 examples since S32DS v3.4 + S32K3 RTD 2.0.3. As you know, S32K3 has many derivatives, so to reduce effort, in the most recent RTD releases we only provide examples for K344, K358, and K396.
Would you please test Adc_example_S32K312 of RTD203? The TEST_FAIL=0 after running Adc_Calibrate API. I test it on S32K312EVB-Q172, Chip information: P32K312NHVPBS 0P09C CTZZ2124A.
If you do not encounter TEST_FAIL problem when testing Adc_example_S32K312 of RTD203, it is recommended to refer to this example to configure the project in the new version of RTD and S32DS.
Adc_example_S32K312 of RTD203 works in S32DS 3.4.3 on S32K312 EVB Rev A. The RTD does not support 100 pin HDQFP package so I am unable to validate on my custom board. That pin package is not supported until November 28, 2023 in RTD 4.0 with DS 3.5. I am also unable to install the newer RTD in the old DS or the old RTD in the new DS.
Using DS3.5, RTD 4 Patch 4 and the K312 100HDQFP package, I manually set up a new project using the working example as my guide. I copied all settings exactly as best as the new style of configurator allowed. The new project is attached and has the same calibration failure, at the same point I experienced before.
Strange. I tested your attached example on S32DS v3.5.8+S32K3 RTD 4.0.0 P20 with S32K312EVB-Q172 RevA. ADC Calibration successful.
Please check whether your board’s power supply, VREFH and other designs comply with S32K3 MCUs for General Purpose – Hardware Design Package.
That is great it works on another board with another DS version too. It also ran on my EVB when I switched to use the 172 pin package. On our custom board though we are using the 100 pin HDQFP package, we are also using an 8MHz external oscillator rather than the 16MHz on the EVB. I did adjust my clocks accordingly for this example to make all the final numbers match the example final numbers. I am also certain that the clocking is set up correctly as I am able to use the CAN module at the expected speeds.
I have checked through the documentation on hardware set up and layout and I am reasonably certain ours is correct, but I have attached a screen snip of our schematics for your review as well.
Looking at VREFH on the eval board and comparing to our custom board's VREFH, we noticed that the custom board has a much noisy voltage. We are working on a solution to test.