比特31 BGVRRDY:带隙电压/ADC参考电压状态位1=带隙电压和ADC参考电压(VREF)准备就绪0=要么或带隙电压和ADC参考电压(VREF)都不是READYDATA处理,仅在BGVRRDY由硬件设置之后才有效,所以应用程序代码必须检查BGVRRDY位,以确保数据的有效性。当AN(ADCCON1和lt;15和gt)=0时,该位设置为“0”。除此寄存器之外,在整个数据表中找不到任何关于“带隙电压”的参考。所以我假设没有别的东西可以让我考虑到带隙基准。这样就留下了ADC参考电压。我有VREF+SET到3.2V。AVDD设置为3.3V。如果我想使用AVDD和AVSS或者1,如果我想使用VREF+和AVSF和FRU,我认为ADCCON3VREFSEL&LT 2:0&GT应该是0。我已经尝试了所有的8个数字,仍然没有得到状态位去影响什么?这是我的设置代码,扫描AN46、AN3、AN4、AN5、AN29。A/CCON2BITS.BGVRRDY);(或)等待参考电压RADYI从“23-3扫描多输入”的例子中获得了大部分,这是家庭参考手册的第22节12位高速SAR ADC。我错过了什么,或者没有设置或设置错误来保持这一点不高?基普
以上来自于百度翻译
以下为原文
bit 31 BGVRRDY: Band Gap Voltage/ADC Reference Voltage Status bit
1 = Both band gap voltage and ADC reference voltages (VREF) are ready
0 = Either or both band gap voltage and ADC reference voltages (VREF) are not ready
Data processing is valid only after BGVRRDY is set by hardware, so the applica
tion code must check that
the BGVRRDY bit is set to ensure data validity. This bit set to '0' when ON (ADCCON1<15>) = 0.
I can not find any reference to "Band Gap Voltage" in the whole datasheet except for this register. So I am assuming there is nothing else for me to set with regards to band gap reference.
So that leaves ADC Reference Voltage.
I have VREF+ set to 3.2V.
I have AVDD set to 3.3V.
I think ADCCON3 VREFSEL <2:0> should be 0 if I want to use AVDD and AVSS or 1 if I want to use VRef+ and AVSS
And in frustration I have tried all 8 numbers and still do not get the Status bit to go to 1
What else affects it?
Here is my setup code to scan AN46, AN3, AN4, AN5, AN29.
void InitAnalog(void)
{
/* Configure Analog Pins H
ARMony should have done it, just making sure. */
ANSELAbits.ANSA1 = 1; // RA1 AN29 PIN 38 Heater Voltage
ANSELBbits.ANSB3 = 1; // RB3 AN3 Pin 22 Voltage In
ANSELBbits.ANSB4 = 1; // RB4 AN4 Pin 21 PS1
ANSELBbits.ANSB6 = 1; // RB6 AN46 Pin 26 PS2
ANSELBbits.ANSB10 = 1; // RB10 AN5 Pin 34 POT
ANSELAbits.ANSA10 = 1; // RA10 +Vref Pin 29 Reference voltage
TRISAbits.TRISA1 = 1; // RA1 Input
TRISBbits.TRISB3 = 1; // RB3 Input
TRISBbits.TRISB4 = 1; // RB4 Input
TRISBbits.TRISB6 = 1; // RB6 Input
TRISBbits.TRISB10 = 1; // RB10 Input
TRISAbits.TRISA10 = 1; // RA10 Input
/* Configure ADCCON1 */
ADCCON1 = 0; // No ADCCON1 features are enabled including: Stop-in-Idle, turbo,
// CVD mode, Fractional mode and scan trigger source.
ADCCON1bits.SELRES = 3; // ADC7 resolution is 12 bits
ADCCON1bits.STRGSRC = 1; // Select scan trigger.
// ADC Calibration Data
ADC0CFG = DEVADC0;
ADC1CFG = DEVADC1;
ADC2CFG = DEVADC2;
ADC3CFG = DEVADC3;
ADC4CFG = DEVADC4;
ADC7CFG = DEVADC7;
ADCEIEN1 = 0; // Interrupts Disabled
ADCEIEN2 = 0; // Interrupts Disabled
/* Configure ADCCON2 */
ADCCON2bits.SAMC = 13; // ADC7 sampling time = 5 * TAD7
ADCCON2bits.ADCDIV = 1; // ADC7 clock freq is half of control clock = TAD7
/* Initialize warm up time register */
ADCANCON = 0;
ADCANCONbits.WKUPCLKCNT = 5; // Wakeup exponent = 32 * TADx
/* Clock setting */
ADCCON3bits.ADCSEL = 0; // Select input clock source Peripheral Clock 100 MHz
ADCCON3bits.CONCLKDIV = 1; // Control clock frequency is half of input clock 50 MHz
//ADCCON3bits.VREFSEL = 0; // Select AVDD and AVSS as reference source 3.3V
ADCCON3bits.VREFSEL = 1; // Select External VREF+ and AVSS as reference source 3.2V
ADC0TIMEbits.ADCDIV = 1; // ADC0 clock frequency is half of control clock = TAD0 25 MHz
ADC0TIMEbits.SAMC = 13; // ADC0 sampling time = 5 * TAD0
ADC0TIMEbits.SELRES = 3; // ADC0 resolution is 12 bits
ADC1TIMEbits.ADCDIV = 1; // ADC1 clock frequency is half of control clock = TAD0 25 MHz
ADC1TIMEbits.SAMC = 13; // ADC1 sampling time = 5 * TAD0
ADC1TIMEbits.SELRES = 3; // ADC1 resolution is 12 bits
ADC3TIMEbits.ADCDIV = 1; // ADC3 clock frequency is half of control clock = TAD0 25 MHz
ADC3TIMEbits.SAMC = 13; // ADC3 sampling time = 5 * TAD0
ADC3TIMEbits.SELRES = 3; // ADC3 resolution is 12 bits
ADC4TIMEbits.ADCDIV = 1; // ADC4 clock frequency is half of control clock = TAD0 25 MHz
ADC4TIMEbits.SAMC = 13; // ADC4 sampling time = 5 * TAD0
ADC4TIMEbits.SELRES = 3; // ADC4 resolution is 12 bits
/* Select analog input for ADC modules, no presync trigger, not sync sampling */
ADCTRGMODE = 0;
ADCTRGMODEbits.SH1ALT = 1; // ADC1 = AN46
/* Select ADC input mode */
ADCIMCON1 = 0; // All Unsigned Data and Single ended
ADCIMCON2 = 0; // All Unsigned Data and Single ended
/* Configure ADCGIRQENx */
ADCGIRQEN1 = 0; // No interrupts are used.
ADCGIRQEN2 = 0;
/* Configure ADCCSSx */
ADCCSS1 = 0; // Clear all bits
ADCCSS2 = 0;
ADCCSS1bits.CSS1 = 1; // AN46 (Class 1) set for scan
ADCCSS1bits.CSS3 = 1; // AN3 (Class 1) set for scan
ADCCSS1bits.CSS4 = 1; // AN4 (Class 1) set for scan
ADCCSS1bits.CSS5 = 1; // AN5 (Class 1) set for scan
ADCCSS1bits.CSS29 = 1; // AN29 (Class 3) set for scan
/* Configure ADCCMPCONx */
ADCCMPCON1 = 0; // No digital comparators are used. Setting the ADCCMPCONx
ADCCMPCON2 = 0; // register to '0' ensures that the comparator is disabled.
ADCCMPCON3 = 0; // Other registers are ?don't care?.
ADCCMPCON4 = 0;
ADCCMPCON5 = 0;
ADCCMPCON6 = 0;
/* Configure ADCFLTRx */
ADCFLTR1 = 0; // No oversampling filters are used.
ADCFLTR2 = 0;
ADCFLTR3 = 0;
ADCFLTR4 = 0;
ADCFLTR5 = 0;
ADCFLTR6 = 0;
/* Set up the trigger sources */
ADCTRG1 = 0;
ADCTRG1bits.TRGSRC1 = 3; // Set AN1 (Class 1) to trigger from scan source
ADCTRG1bits.TRGSRC3 = 3; // Set AN3 (Class 1) to trigger from scan source
ADCTRG2 = 0;
ADCTRG2bits.TRGSRC4 = 3; // Set AN4 (Class 1) to trigger from scan source
ADCTRG2bits.TRGSRC5 = 3; // Set AN5 (Class 2) to trigger from scan source
ADCTRG3 = 0;
// AN29 (Class 3) always uses scan trigger source
/* Early interrupt */
ADCEIEN1 = 0; // No early interrupt
ADCEIEN2 = 0;
/* Turn the ADC on */
ADCCON1bits.ON = 1;
/* Wait for voltage reference to be stable */
NOP;
NOP;
NOP;
while(ADCCON2bits.REFFLT); // Wait if there is a fault with the reference voltage
while(!ADCCON2bits.BGVRRDY); // Wait until the reference voltage is ready
while(ADCCON2bits.REFFLT); // Wait if there is a fault with the reference voltage
/* Enable clock to analog circuit */
ADCANCONbits.ANEN1 = 1; // Enable the clock to analog bias ADC1
ADCANCONbits.ANEN3 = 1; // Enable the clock to analog bias ADC3
ADCANCONbits.ANEN4 = 1; // Enable the clock to analog bias ADC4
ADCANCONbits.ANEN7 = 1; // Enable, ADC7
/* Wait for ADC to be ready */
while(!ADCANCONbits.WKRDY1); // Wait until ADC0 is ready
while(!ADCANCONbits.WKRDY3); // Wait until ADC0 is ready
while(!ADCANCONbits.WKRDY4); // Wait until ADC0 is ready
while(!ADCANCONbits.WKRDY7); // Wait until ADC7 is ready
/* Enable the ADC module */
ADCCON3bits.DIGEN1 = 1; // Enable ADC1
ADCCON3bits.DIGEN3 = 1; // Enable ADC3
ADCCON3bits.DIGEN4 = 1; // Enable ADC4
ADCCON3bits.DIGEN7 = 1; // Enable ADC7
}
It stops forever at the line
while(!ADCCON2bits.BGVRRDY); // Wait until the reference voltage is ready
I took most of this from the example "22-3 Scanning Multiple Inputs" in the Section 22 12-bit High Speed SAR ADC of the family reference manual. |
What am I missing or not setting or setting wrong to keep that bit from going high?
Kip