Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need help using dspic33fj input capture

Status
Not open for further replies.

hoseinagha

Newbie level 1
Joined
Oct 24, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,290
I am using DSPIC33FJ256GP710 and using code below for setting input capture 1.
But the result is wrong. It seems that Input capture is not using input frequency and result is much higher frequency.

unsigned int ic1_prev_buf ;
void __attribute__((__interrupt__)) _IC1Interrupt( void )
{
unsigned int tmp,icvalue;
tmp = IC1BUF;

if(ic1_prev_buf>tmp)
icvalue = tmp + 65535 - ic1_prev_buf;
else
icvalue = tmp - ic1_prev_buf;
ic1_prev_buf = tmp;
IFS0bits.IC1IF = 0;
}

void timer2init(void)
{
//cpu clock 46080000
//timer 2 prescallar : 64
T2CON = 0;
T2CONbits.TCKPS=2;
T2CONbits.TON=1;
PR2=0xffff;
}

void ic1_init(void)
{
//TRISDbits.TRISD8=1;
//IC1CON=0;
IC1CONbits.ICM=3;
IC1CONbits.ICTMR=1;
IC1CONbits.ICI=0;
IFS0bits.IC1IF = 0;
IPC0bits.IC1IP = 7;
IEC0bits.IC1IE=1;
}

Any help is appreciated.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top