Electronics > Projects, Designs, and Technical Stuff

About multiple interrupt ISR (PIC)

(1/2) > >>

danielks:
Can anyone teach me how to write the coding for Interrupt polling type in Hi-tech C ?

For example Timer Interrupt and CCP interrupt together...  :'(

Mechatrommer:
loop:
   if (PIR1[CCP1IF]) doMe();
   if (PIR1[TMR1IF]) doYou();
goto loop;

something like that?

danielks:
Now I have a coding which consist of 5 interrupts in the ISR. But i only try with 1 timer interrupt and 1 CCP interrupt. I set the timer interrupt priority to high and CCP to low but when ever CCP interrupt happen, the program hang. if I set more than 1 CCP interrupt non of the interrupt will works and program Hang.

Mechatrommer:
your code pls? ... this topic should be moved to microcontroller section.

danielks:
sorry about that..  :-[

my coding..

void interrupt ISR()
{   
      if(TMR0IE==1&&TMR0IF==1)         
         {
            t++;            //increase counter by 1
            if(t<s1){
               motor1=1;
            }
            if(t<s2){
               motor2=1;
            }
            if(t<s3){
               motor3=1;
            }
            if(t<s4){
               motor4=1;
            }
                                                                                                                    
            if(t==s1){
               motor1=0;
            }
            if(t==s2){
               motor2=0;
            }
            if(t==s3){
               motor3=0;
            }
            if(t==s4){
               motor4=0;
            }
   
            if(t==1000) //Reset counter to 0
            {
               t=0;
            }
         
         TMR0IF=0;  //Reset interrupt flag to 0   
         TMR0=250;
         
      }
      
if (CCP4IE==1&&CCP4IF==1)
   {
   count1++;
   CCP4IF=0;
      if (count1==1)
         {
         t1=TMR1;
         count1==1;
         CCP4CON=0b00000100;     //falling edge detection
         }
      if (count1==2)
         {
         t2=TMR1;
         count1=0;
         CCP4CON=0b00000101;   //rising edge detection
         }
         TMR1=0;
         
   }
   
   
   if(CCP5IE==1 && CCP5IF==1)
   {
   count++;
   CCP5IF=0;
      if (count==1)
         {
         t11=TMR1;
         count==1;
         CCP5CON=0b00000100;     //falling edge detection
         }
      if (count==2)
         {
         t22=TMR1;
         count=0;
         CCP5CON=0b00000101;   //rising edge detection
         }
         TMR1=0;
   }
}

With the CCP5 interrupt in the coding just wont run. it hangs.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod