Post Go back to editing

ADuC845 Delay

Category: Software

I am designing an ADC card using ADuC845. In Keil, I wrote a C-code for the same purpose. I provide a sine input signal of 1Hz frequency and output 1000 readings during testing. But, there are a few consecutive pairs of the same reading. There are around 10 pairs of the same reading among those 1000 readings. This is because of a delay during the configuration of ADC0CON1 and ADC0CON2. How much delay should I provide to avoid the repetition of readings at adjacent places? Or there are other places where I need to put a delay?

  • Hi,

    Can you further explain your setup? Are you trying to measure 1000 points within a single period, or are you trying to measure 1000 points at different times?

    You mentioned the delay during the configuration of ADC0CON1 and ADCCON2. Did you add a delay before the configuration of the registers?



  • I am running my code which does the configuration and conversion of ADC values in a for loop (1000 times). 

    No, I added delay after configuration of both the registers.

  • Have you tried removing the delay after configuring both registers?

  • Yes, I tried removing the delay. But, it is required to put a delay after the configuration of both the registers, otherwise their values are not updated, and it requires more cycles to update their values.

  • How are you configuring the ADC? What are the values of the ADC registers?

    You can try something similar to the ADC configuration in the example code. It doesn't need to update the ADC configuration each time to get the ADC value.

    // Author        : ADI - Apps  
    // Date          : 16 October 2003
    // File          : 847uart.c
    // Hardware      : ADuC845, ADuC847, ADuC848 (taking into account fact that the ADuC848 is a 16-bit ADC)
    // Description   : sample program that performs ADC conversions in
    //                 continuous mode and sends results to a PC via the
    //                 UART. Operates on the RTD (PT100) on the eval board
    //				   via Ain1->Ain2 ADC inputs. The switches (S4) on the
    //				   eval board must be set as follows to get this program
    //				   working correctly...RTD AIN1, RTD AIN2, RTD REFIN+
    //				   and RTD REFIN- must be set to ON. All other switches
    //				   must be off.
    #include <stdio.h>
    #include <ADuC845.h>    //To use this with an ADuC847 or ADuC848, simply change the
    					    //header file to <ADuC847.h> or <ADuC848>
    sbit LED = 0x0B4;
    void ADC_int () interrupt 6
    	LED ^= 1;
    	printf("%bX%bX%bX",ADC0H,ADC0M,ADC0L);  //Remove ADC0L when using the ADuC848
        RDY0 = 0;
    void main (void)
     			//Configure UART
        T3CON = 0x83;	//9600 Baud rate
        T3FD = 0x12;
        SCON = 0x52;
        ICON = 0x01;	//Turn on IEXC1 source to drive RTD.
        SF = 0x200;
        ADC0CON1 = 0x22;	//Full Buffer, Unipolar, 80mV range.
        ADC0CON2 = 0x4A;	//Refin+/-, Ain1->Ain2
        EADC = 1;           //Enable ADC Interrupt
        EA = 1;             //Enable Global Interrupts
        ADCMODE = 0x23;	// continuous conversion on Main channel on main channel