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

HI-TECH translate

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



Joined: 18 Jan 2006
Posts: 9

View user's profile Send private message

HI-TECH translate
PostPosted: Wed Feb 27, 2008 8:53 am     Reply with quote

Hi.I need translate this code from hi-tech compiler to CCS.Is a timer interrupt????Thanks
Code:

void interrupt isr(void)
{

   if (TMR1IF==1)
   {
      counter++;
      if (counter==keepalive)         //131 ms * counter keep_alive
      {
         //Go away I'm keep aliving

         counter=0;

         //CODE
}
      TMR1IF=0;
   }
}

_________________
To Pic Or No To Pic
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Wed Feb 27, 2008 9:39 am     Reply with quote

Yes, it is an -open- TMR1 interrupt handler. Cool

All you need is to define how to access TMR1IF. In most 16F series, it is the Bit0 of the
PIR1 Reg.
Credit to Mark who posted an alternative header with all the byte and bits definitions for
most 16F devices using union and structs. In this way it is possible to access a single
bit within a Register.

Code:

unsigned char PIR1;
#locate PIR1=0x0C

struct {
    unsigned char TMR1IF:1;
    unsigned char TMR2IF:1;
    unsigned char CCP1IF:1;
    unsigned char SSPIF:1;
    unsigned char TXIF:1;
    unsigned char RCIF:1;
    unsigned char ADIF:1;
    unsigned char PSPIF:1;
} PIR1bits ;
#locate PIR1bits=0x0C


Humberto
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 27, 2008 12:41 pm     Reply with quote

Here is the translation to CCS:
Code:

#int_timer1
void timer1_isr(void)
{
 counter++;

 if(counter == keepalive)   
   {
    counter=0;
   }

}

Don't put in any code for the TMR1IF flag. CCS handles it for you.
Saratoga



Joined: 18 Jan 2006
Posts: 9

View user's profile Send private message

PostPosted: Thu Feb 28, 2008 1:29 am     Reply with quote

Huooo .OK..

"if (TMR1IF==1)" is only for HI-tech.
It s 131ms timer x counter. I understand now.
Thanks to all.

The program is the ELM323 OBD chip firmware.
http://www.obdchip.com/node/20. I translate definitions code to CCS(gracias humberto XD).
_________________
To Pic Or No To Pic
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