全文预览

微芯单片机4通道AD采样调试程序

上传者:叶子黄了 |  格式:docx  |  页数:2 |  大小:12KB

文档介绍
.ANSB2 = 1; // Ensure AN2/RB2 is analogРР?ANSELBbits.ANSB3 = 1; // Ensure AN5/RB5 is analogР?/* Initialize and enable ADC module */Р?AD1CON1 = 0x000C; // Enable simultaneous sampling and auto-sampleР?AD1CON2 = 0x0300; // Sample 4 channelsР?AD1CON3 = 0x000F;Р?AD1CON4 = 0x0000;Р?AD1CSSH = 0x0000;Р?AD1CSSL = 0x0000;Р?AD1CHS0bits.CH0SA = 5; // Select AN5 for CH0 +ve inputР?AD1CHS0bits.CH0NA = 0; // Select Vref- for CH0 -ve inputР?AD1CHS123bits.CH123SA = 0; // Select AN0 for CH1 +ve inputР?// Select AN1 for CH2 +ve inputР?// Select AN2 for CH3 +ve inputР?AD1CHS123bits.CH123NA = 0; // Select Vref- for CH1/CH2/CH3 -ve inputsР?AD1CON1bits.ADON = 1;Р?//Delay(20);Р}Рvoid Delay(unsigned int delay)Р?{Р?for (i = 0; i < delay; i++)Р??{Р??__asm__ volatile ("repeat #39");Р??__asm__ volatile ("nop");Р??}Р}

收藏

分享

举报
下载此文档