打印

S3C44B0怎么AD转换并LCD输出呢??

[复制链接]
1681|5
手机看帖
扫描二维码
随时随地手机跟帖
沙发
mxh0506| | 2008-11-4 22:15 | 只看该作者

我这里有一些以前写的ADC的代码,给你参考吧

// ADC ISR
__arm  void  Adc_CompleteISR_Handler (void)
{
    rI_ISPC = BIT_ADC;       // clear pending bit of adc
    wAdcResult[wAdcPos] = rADCDAT;
    wAdcPos++;
    if(wAdcPos < MAX_ADC_BUFFLEN){
        BSP_ADC_StartChannel(wAdcCh);
    }else{
        OSSemPost(pSemAdc);    // signal sampling over
    }
}
/*
    Initialize the ADC, dwAdcRate is in Hz
    the larger the PSR is, the lower the input current will be
    so lower ADC rate can lead to more accurate AD result
*/
void BSP_ADC_Init(INT32U dwAdcRate)
{
    rADCPSR = MCLK/(32*dwAdcRate)-1;
    rADCCON = 0;    // activate ADC clock, no operation, CH0
    pISR_ADC = (unsigned) Adc_CompleteISR_Handler;    // set ISR vector
    rINTMSK &= ~BIT_ADC;    // enable inperrupt
}
// switch to sepcified channel, and start conversion
// uiChannel must be within 0 to 7
void BSP_ADC_SwitchChannel(INT16U wChannel)
{
    wAdcPos = 0;
    wAdcCh = wChannel;
    rADCCON = 0x01 | (wChannel << 2);    // start conversion
}
// start ADC on specified channel
// uiChannel must be within 0 to 7
void BSP_ADC_StartChannel(INT16U wChannel)
{
    rADCCON = 0x01 | (wChannel << 2);
}

使用特权

评论回复
板凳
mxh0506| | 2008-11-4 22:21 | 只看该作者

这个是ADC任务

void TaskSampling(void * pParam)
{
    INT8U byRet;
    INT16U uiCh;
    OS_CPU_SR  cpu_sr = 0;
    uiCh = 0;
    BSP_ADC_SwitchChannel(uiCh);
    while(1)    
    {
        if(pSemAdc){    // semaphore created successfully
            OSTimeDly(5);
            OSSemPend(pSemAdc,0,&byRet);
            if(OS_NO_ERR == byRet){
                wAdc[uiCh] = wAdcResult[2];
                bAdcRdy = 1;
                uiCh++;
                uiCh %= 2;
                BSP_ADC_SwitchChannel(uiCh);
            }
        }
    }
}

使用特权

评论回复
地板
mxh0506| | 2008-11-4 22:24 | 只看该作者

若再加LCD显示,只需再添加相应的驱动和任务就行了

使用特权

评论回复
5
雅子|  楼主 | 2008-11-12 09:55 | 只看该作者

我参考一下再回复

使用特权

评论回复
6
雅子|  楼主 | 2008-11-13 14:16 | 只看该作者

电路图?

用LPC2124进行AD转换并LCD输出,怎么玩呢???

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

6

帖子

0

粉丝