#include "p24fxxxx.h"
void init(void)
{
//
//
//
CLKDIV = 0x3000;
//
//
//
AD1PCFG = 0xF5FC;
AD1CON1 = 0x0000;
//AD1CHS = 0x000B;
//AD1CHS = 0x0001;
AD1CSSL = 0x0A03;
AD1CON3 = 0x1F02;
AD1CON2bits.CSCNA = 1;
AD1CON2bits.SMPI = 3;
AD1CON1bits.ADON = 1;
//SRbits.IPL = 2;
IFS0bits.AD1IF = 0;
IEC0bits.AD1IE = 1;
T1CON = 0;
TMR1 = 0;
PR1 = 0xFFFF;
IPC0bits.T1IP = 0x4;
IFS0bits.T1IF = 0;
IEC0bits.T1IE = 1;
}
void delay(int n)
{
for(;n!=0;n--)
{
asm( "nop");
asm( "nop");
asm( "nop");
asm( "nop");
}
}
void ProcADC(void)
{
int n,*BufPtr;
AD1CON1bits.SAMP = 1;
delay(50);
AD1CON1bits.SAMP = 0;
while (IFS0bits.AD1IF==1)
IFS0bits.AD1IF = 0;
//while (AD1CON1bits.DONE == 1)
//AD1CON1bits.DONE = 0;
BufPtr =(int*)&ADC1BUF0;
for(n = 0;n<4;n++)
{
vDac[n] = *BufPtr;
BufPtr++;
}
}
unsigned int tmrCount1;
unsigned int tmrCount2;
void __attribute__ ((interrupt, no_auto_psv)) _T1Interrupt(void)
{
IFS0bits.T1IF = 0;
if (tmrCount1 == 0x000F) {
adcStrFlg = 1;
tmrCount1 = 0;
}
else {
tmrCount1++;
}
if (tmrCount2 == 0x000F) {
frontPicRdFlg = 1;
tmrCount2 = 0;
}
else {
tmrCount2++;
}
}
int main(void)
{
init();
ProcADC();
while(1){
ProcADC();
}
感觉设置上没有问题了啊 为什么就是没有中断呢 而且和T1的中断还有影响
此帖出自
小平头技术问答
一周热门 更多>