CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

how to setup IC1, IC2, IC7 and IC8 in dsPIC30F4011

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
neohimura



Joined: 08 Feb 2011
Posts: 14

View user's profile Send private message

how to setup IC1, IC2, IC7 and IC8 in dsPIC30F4011
PostPosted: Thu Apr 21, 2011 7:22 am     Reply with quote

Hi,
I wanted to use IC1, IC2, IC7 and IC8 on my dsPIC30F4011 to measure the frequency of 4 pulse. How do I setup the dsPIC to do this? I manage to insert the interrupt before main().How do i get the captured timer3 value in dspic? (in pic16 example CCP_1 is used)

Code:
int16 isr_ic_delta;

#int_IC1
void  IC1_isr(void)
{
int16 current_ic;
static int16 old_ic= 0;

current_ic = ?????

isr_ic_delta = current_ic - old_ic;
old_ic = current_ic;
}

#int_IC2
void  IC2_isr(void)
{

}

#int_IC7
void  IC7_isr(void)
{

}

#int_IC8
void  IC8_isr(void)
{

}



inside main() i added the following code

Code:
   setup_capture(1,CAPTURE_RE|CAPTURE_TIMER3);
   setup_timer3(TMR_INTERNAL | TMR_DIV_BY_8);
   setup_capture(2,CAPTURE_RE|CAPTURE_TIMER3);
   setup_timer3(TMR_INTERNAL | TMR_DIV_BY_8);
   setup_capture(7,CAPTURE_RE|CAPTURE_TIMER3);
   setup_timer3(TMR_INTERNAL | TMR_DIV_BY_8);
   setup_capture(8,CAPTURE_RE|CAPTURE_TIMER3);
   setup_timer3(TMR_INTERNAL | TMR_DIV_BY_8);

   enable_interrupts(INT_IC1);
   enable_interrupts(INT_IC2);
   enable_interrupts(INT_IC7);
   enable_interrupts(INT_IC8);


is this enough to get the input capture to function? I didn't find any examples done on dsPIC. I hope you can help me. Thank you.
younder



Joined: 24 Jan 2013
Posts: 53
Location: Brazil

View user's profile Send private message

PostPosted: Sat May 14, 2016 8:04 pm     Reply with quote

Hi Everyone,

I've searched in the forum for any thread that shows how to use the input capture module, but I couldn't find anything. Can anyone can help me understand how to set up IC7 & IC8 (Rising edge) on a DSPIC30F4012?

I'm using external interrupt (INT1 & INT2), but as my low frequency software PWM did not work well, I was wondering if I could release these pins so that I would be able to use pwm module (OC1 & OC1). In order to do that I need to move my code to a ISR handler IC7 & IC8.

Any help would be appreciated,
Hugo


CCS V 5.057
_________________
Hugo Silva
Ttelmah



Joined: 11 Mar 2010
Posts: 19447

View user's profile Send private message

PostPosted: Sun May 15, 2016 12:55 am     Reply with quote

The ex_capture.c example shows how to do this on the DSPIC. This probably postdates the original post on this thread.

It's both easier and more complex. Key differences are that the captures have a FIFO, so you can capture events much 'closer together' than is possible using the CCP. Gives you time to record one reading before the next one happens. Smile

The example also has the option to generate a PWM output, so this can be used as the source for measurement.

The value from the capture, is retrieved using 'get_capture'.

In the example, they do a single 'pair' of captures, and do the maths externally. This is actually done to make it easier if the capture has to handle a timer overflow, but generally doesn't matter.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group