LPC1225 ADC

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC1225 ADC

857件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Redbull68 on Wed May 28 05:31:42 MST 2014
Hi,

I try to use the on chip ADC but I have a problem with the result.
I use the software control to start and stop acquisiton on AD0 pin where a generator is connected to have a stable voltage.

void HalAdcInit(void)
{
    // Configure pin as ADC peripheral
    IOCON_PIO0_30 |= 3;         // channel AD0
    IOCON_PIO0_30 &= 0xFF7F;    // Pin as analog
    
    PDRUNCFG_bit.ADC_PD = 0;    // Enable Power on ADC
    SYSAHBCLKCTRL_bit.ADC = 1;  // Enable ADC clock
    
    AD0CR_bit.CLKDIV = 3;       // Divider (value + 1) for APB clock to have an ADC clock
                                // less than 9 MHz
                                // ADC clock = System clock / (CLKDIV + 1)
                                //             33177600 / 4
                                //             8294400 Hz
    
    AD0CR_bit.SEL = 1;
    
    AD0CR_bit.BURST = 0;        // Conversion are software controlled
    AD0CR_bit.START = 0;        // A/D conversion stop
    
}/*END HalAdcInit*/


void HalAdcTest2(void)
{
    UVAR_16     i;
    UVAR_16     tab[400];
    
    memset(tab, 0, sizeof(tab));
    while (1)
    {
        for (i = 0; i < 400; i++)
        {
            AD0CR_bit.START = 1;
            while (AD0DR0_bit.DONE != 1);
            AD0CR_bit.START = 0;
            tab = AD0DR0_bit.RESULT;
        }
    }
}


I do the initialisation and after only HalAdcTest2 function running.
When i run the loop only 1 time, data in tab is good but if I launch continually the function and i stop in the fly, data in tab is not good( sequence of 0x003F and 0x03C1)
ラベル(1)
0 件の賞賛
返信
1 返信

786件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nxp_apps on Fri May 30 16:54:25 MST 2014
Hi,

Have you tried to use the ADC example from the sample code?

http://www.lpcware.com/content/nxpfile/lpc12xx-cmsis-driver-library-keil

Thanks.

nxp_support
0 件の賞賛
返信