|
|
View previous topic :: View next topic |
Author |
Message |
neohimura
Joined: 08 Feb 2011 Posts: 14
|
how to setup IC1, IC2, IC7 and IC8 in dsPIC30F4011 |
Posted: Thu Apr 21, 2011 7:22 am |
|
|
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
|
|
Posted: Sat May 14, 2016 8:04 pm |
|
|
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: 19509
|
|
Posted: Sun May 15, 2016 12:55 am |
|
|
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.
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. |
|
|
|
|
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
|