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 CCS Technical Support

PIC16f630 error in interrupt with serial (SOLVED)

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



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message

PIC16f630 error in interrupt with serial (SOLVED)
PostPosted: Tue Oct 12, 2010 11:37 am     Reply with quote

I fogot put #int_TIMER1 in function.

*************************************************************
Hi ever body.

In the code below when I enable interrupt TIMER1 the program enters an infinite loop. But it works ok without interruption.
Can anyone help?

Thanks in advance.


Code:
#include <16F630.h>

#FUSES NOWDT             // No Watch Dog Timer
#FUSES HS                // High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPROTECT         // Code not protected from reading
#FUSES NOBROWNOUT        // No brownout reset
#FUSES MCLR              // Master Clear pin enabled
#FUSES NOCPD             // No EE protection
#FUSES PUT               // Power Up Timer

#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_A2,rcv=PIN_C0,bits=8, ERRORS)

#define  RL_TX1 PIN_C3
#define  RL_TX2 PIN_A0

//******************************************************************************
//                              Funções
//******************************************************************************

void acionaRlTX1(void);
void acionaRlTX2(void);
void desligaReles(void);

//******************************************************************************
//                         Variaveis globais
//******************************************************************************

int8 contTempo=0,
     segundos=0;
     
char x=0;

int1 flagTempoOver=0,
     flagTX1=0,
     flagTX2=0;
 
//******************************************************************************
//
//******************************************************************************
void  TIMER1_isr(void)
 {
   contTempo++;
   
     if(contTempo==10)
       {
       segundos++;
       contTempo=0;
       }
 
   if(segundos==15)
      {
      flagTempoOver=1;
      }
 
 }
//******************************************************************************
//
//******************************************************************************

void main()
{
 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
 setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
 setup_comparator(NC_NC);
 disable_interrupts(INT_TIMER1);
 disable_interrupts(GLOBAL);
   
 while(1) 
       {               
        if(kbhit())
         {
          x = getc();
         
          if (x=='A')
             {
             acionaRlTX1();
             segundos=0;
             }           
         
          if( x=='B')
             {
             acionaRlTX2();
             segundos=0;
             }           
         }
   
     if(flagTempoOver)
         desligaReles();
   
    }

}

//******************************************************************************
//                   
//******************************************************************************
void acionaRlTX1(void)
{
  if(!flagTX1 && !flagTX2)
     {     
     enable_interrupts(INT_TIMER1);
     enable_interrupts(GLOBAL);
     clear_interrupt(int_timer1);
     output_high(RL_TX1);
     flagTX1=1;
    }           
}
//******************************************************************************
//
//******************************************************************************
void acionaRlTX2(void)
{
  if(!flagTX1 && !flagTX2)
    {
    enable_interrupts(INT_TIMER1);
    enable_interrupts(GLOBAL);
    clear_interrupt(int_timer1);
    output_high(RL_TX2);
    flagTX2=1;   
    }             
}

//******************************************************************************
//           Desliga os reles e reinicia todas as variaveis
//******************************************************************************
void desligaReles(void)
{
  disable_interrupts(INT_TIMER1);
  disable_interrupts(GLOBAL);
 
  output_low(RL_TX1);
  output_low(RL_TX2);
 
  flagTX1=0;
  flagTX2=0;
 
  flagTempoOver=0;
}
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Wed Oct 13, 2010 1:56 am     Reply with quote

You are missing the #INT_TIMER1 directive prior to your routine:-

#INT_TIMER1
void TIMER1_isr(void)

Hope this helps.
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