Reading ADC Through eFPGA On The EOS-S3
Unfortunately, the ADC needs to be configured by the M4-F core in EOS. The ADC was designed for measuring the voltage so, it fairly slow between 2.5mS to 25mS and only supports 12-bit.
The operation of the ADC is as follows
ADC Conversion Procedure:
1. Select which ADC channel input 0 or 1.
a.
Program ADC_Control[1] = 0 or 1 depending on ADC channel selected.
2. Setup a 1MHz clock to ADC (C19).
a.
Select the clock source to be HSOSC. Program 0 to CLK_Control_H_1 (0x030) to select the
OSC source.
b. Based on the OSC frequency, program the clock divider to CLK_Control_H_0 (0x028).
i. If OSC prog[11:0] = 0x92d ( default), then OSC is running at 77.07 Mhz. Please
refer to Change the Oscillator Frequency for OSC frequency equation. Then
program divider 77 into CLK_Control_H_0 [8:0] = 77 – 2 = 75 = 0x4B, to get 1
MHz ADC input clock ( C19 ).
c.
Enable the clock gates.
i. Program 1 to CLK_DIVIDER_CLK_GATING (0x124) bit[7]. Enable the C19 root.
ii. Program 1 to C19_CLK_GATE(0x06C). Enable the path clock to ADC.
3. Write 0 to ADC_Control[0] SOC. This will disable the Start-of-Conversion signal to ADC.
4. Apply the voltage to ADC channel 0 or 1. This should match step 1 above.
5. Write 1 to ADC_Control[0] SOC. This will enable the Start-of-Conversion signal to ADC.
6. Poll until ADC_Status[0] EOC is 0. This signals End-of-Conversion is started when low.
7. Poll until ADC_Status[1] EOC is 1. When 1, this signals that ADC has reached End-of-Conversion
of Analog signal into digital value.
8. Read out ADC_Out[11:0] for the digital value.
Write 1 to ADC_Control[0] SOC can only be done by the EOS M4-F core and not the FPGA.
For the ADC to work you also need to ensure that the clock network C19 is enabled.
The operation of the ADC is as follows
ADC Conversion Procedure:
1. Select which ADC channel input 0 or 1.
a.
Program ADC_Control[1] = 0 or 1 depending on ADC channel selected.
2. Setup a 1MHz clock to ADC (C19).
a.
Select the clock source to be HSOSC. Program 0 to CLK_Control_H_1 (0x030) to select the
OSC source.
b. Based on the OSC frequency, program the clock divider to CLK_Control_H_0 (0x028).
i. If OSC prog[11:0] = 0x92d ( default), then OSC is running at 77.07 Mhz. Please
refer to Change the Oscillator Frequency for OSC frequency equation. Then
program divider 77 into CLK_Control_H_0 [8:0] = 77 – 2 = 75 = 0x4B, to get 1
MHz ADC input clock ( C19 ).
c.
Enable the clock gates.
i. Program 1 to CLK_DIVIDER_CLK_GATING (0x124) bit[7]. Enable the C19 root.
ii. Program 1 to C19_CLK_GATE(0x06C). Enable the path clock to ADC.
3. Write 0 to ADC_Control[0] SOC. This will disable the Start-of-Conversion signal to ADC.
4. Apply the voltage to ADC channel 0 or 1. This should match step 1 above.
5. Write 1 to ADC_Control[0] SOC. This will enable the Start-of-Conversion signal to ADC.
6. Poll until ADC_Status[0] EOC is 0. This signals End-of-Conversion is started when low.
7. Poll until ADC_Status[1] EOC is 1. When 1, this signals that ADC has reached End-of-Conversion
of Analog signal into digital value.
8. Read out ADC_Out[11:0] for the digital value.
Write 1 to ADC_Control[0] SOC can only be done by the EOS M4-F core and not the FPGA.
For the ADC to work you also need to ensure that the clock network C19 is enabled.