romel_emperado
Advanced Member level 2
- Joined
- Jul 23, 2009
- Messages
- 606
- Helped
- 45
- Reputation
- 132
- Reaction score
- 65
- Trophy points
- 1,318
- Location
- philippines
- Activity points
- 6,061
Guys I have two modules namely pwm.c and frequency.c.
In pwm.c Im using timer 0 interrupt for my software pwm and in frequency.c Im using the CCP module interrupt..
the code works pretty well if I comment one of the interrupt and compile it..
here is the error..
how to deal this issue?
Thanks so much
---------- Post added at 12:37 ---------- Previous post was at 12:36 ----------
this is my software pwm interrupt.
CCP module interrupt.
---------- Post added at 12:40 ---------- Previous post was at 12:37 ----------
the problem is the whole code works without using two interrupts.. I can only use 1 interrupt
---------- Post added at 12:40 ---------- Previous post was at 12:40 ----------
I tried using two intrrupts before but it is in one module and it works..
In pwm.c Im using timer 0 interrupt for my software pwm and in frequency.c Im using the CCP module interrupt..
the code works pretty well if I comment one of the interrupt and compile it..
here is the error..
symbol "int_func" defined more than once
how to deal this issue?
Thanks so much
---------- Post added at 12:37 ---------- Previous post was at 12:36 ----------
this is my software pwm interrupt.
PHP:
void interrupt softPWM()
{
if(TMR0IF) //Check if it is TMR0 Overflow ISR
{
if(!pwm_flag) //Start of High level
{
pwm_flag = 1; //Set flag
PWMPIN = 1; //Set PWM o/p pin
TMR0 = pwm_width; //Load timer
}
else //Start of Low level
{
pwm_flag = 0; //Clear flag
PWMPIN = 0; //Clear PWM o/p pin
TMR0 = 255 - pwm_width; //Load timer
}
TMR0IF = 0; //Clear Interrupt flag
}
}
CCP module interrupt.
PHP:
void interrupt frequency()
{
static bit pulse_state = 0;
if(PIR1bits.TMR1IF) //timer1 overflow
{
PIR1bits.TMR1IF = 0; //clear flag
FQ = 0;
}
if(PIR1bits.CCP1IF) //event captured
{
PIR1bits.CCP1IF = 0;
switch(pulse_state)
{
case 0:
pulse_state = 1;
TMR1L = 0;
TMR1H = 0;
break;
case 1:
counter = TMR1L; // Get the first 8-bit TIMER0 Counter
counter += (TMR1H << 8); // Get the last 8-bit TIMER0 Counter
FQ = (unsigned int)(1000.0/(counter * 0.000333));
pulse_state = 0;
}
}
}
---------- Post added at 12:40 ---------- Previous post was at 12:37 ----------
the problem is the whole code works without using two interrupts.. I can only use 1 interrupt
---------- Post added at 12:40 ---------- Previous post was at 12:40 ----------
I tried using two intrrupts before but it is in one module and it works..