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

external interrupt (#int_ext)

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







external interrupt (#int_ext)
PostPosted: Mon Dec 17, 2007 2:20 am     Reply with quote

I wrote a interrupt program as below. When input pulse is lower than 100KHz, output pulse is fine(as i expected) but when input pulse is over than 100KHz, output pulse become slow... i dont know why. Please help me if u know it. Thanks

#include <16f873a.h>
#fuses HS,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP

#define SECMAX 4


int sec;

#INT_EXT

void ext_isr(void)
{
sec--;
if(sec==0)
{
sec = SECMAX;
output_low(PIN_B1);
}
else{
output_high(PIN_B1);
}

}

void main (void)
{
EXT_INT_EDGE(L_TO_H);
sec = SECMAX;
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
while(1)
{
}
}
Ken Johnson



Joined: 23 Mar 2006
Posts: 197
Location: Lewisburg, WV

View user's profile Send private message

PostPosted: Mon Dec 17, 2007 7:50 am     Reply with quote

Not sure about the output pulse become slow - do you mean it just doesn't get faster as expected? Anyway . . .

You're probably reaching the pic speed limit. The standard isr pre/post processing added by ccs saves/restores a lot of stuff. Use the FAST keyword on your isr (doesn't save/restore anything). Look at the generated asm code, and add code (if needed) to save/restore only the regs used in the isr.

Ken
cambo
Guest







PostPosted: Mon Dec 17, 2007 6:08 pm     Reply with quote

Yes, as input pulse frequency is faster(over100KHz), output pulse should also become faster too. But it is not.....

I dont make it yet, thanks for ur help anyway... i'm trying Sad
cambo
Guest







PostPosted: Mon Dec 17, 2007 10:03 pm     Reply with quote

Can u give me some examples?
Thanks
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

external interrupt
PostPosted: Tue Dec 18, 2007 4:15 am     Reply with quote

if the controller works at 20MHz with 200ns=PC, you have 50 pc between interrupts, 100khz will be more or less the limit in C, with FAST maybe more. In asembler, your program will be able to handle arround 400khz.
joseph
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