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

No external interrupt with PIC12F675??

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







No external interrupt with PIC12F675??
PostPosted: Fri Jan 24, 2003 12:52 am     Reply with quote

I have tried multiple methods to get an external interrupt to work with CPM programming PIC12F675s. The interrupt flag never gets set. Example code (trying to trigger by pulling GP2 low):

////////////////////////////////////////////////////////
//trying to make the INT external interrupt on GP2 work
//to switch state of a couple of LEDs on GP4,5
////////////////////////////////////////////////////////
#include <12f675.h>
#fuses INTRC_IO,PUT,NOWDT,NOPROTECT,NOMCLR, BROWNOUT
#use delay(clock=4000000)
//define IO pins
#bit gpio5 =0x05.5
#bit gpio4 =0x05.4
#bit gpio3 =0x05.3
#bit gpio2 =0x05.2
#bit gpio1 =0x05.1
#bit gpio0 =0x05.0
#use fast_io(a)

#byte OSCCAL = 0x90
#rom 0x3ff = {0x3470} /// input the calibration code
#int_ext
void external_handler(void)
{
gpio5=!gpio5; //instantly flip LEDs on external interrupt
gpio4=!gpio4;
delay_ms(100);
}

#int_default
void default_isr(void)
{}

main()
{
//setup i/o
set_tris_a(0b001100); //GP0,1,4,5 output; 2,3 input
gpio5=1; gpio4=0; gpio1=0; gpio0=0; //turn on LED on gp5

//set timer0 not to use GP2
setup_counters(rtcc_internal, rtcc_div_2);

//setup interrupts
enable_interrupts(int_ext);
ext_int_edge(h_to_l); //GP2 is pulled high with resistor
enable_interrupts(global);

//loop and wait for interrupt
while(true)
{
delay_ms(2500);
gpio5=!gpio5; //toggle LEDs just to show program is running
gpio4=!gpio4;
}
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 10958
Tomi
Guest







Re: No external interrupt with PIC12F675??
PostPosted: Fri Jan 24, 2003 1:53 am     Reply with quote

<font face="Courier New" size=-1>Remove your delay_ call from the ISR. ITs are disabled under execution of delay_ms() call in main() (so practically always is disabled).

:=I have tried multiple methods to get an external interrupt to work with CPM programming PIC12F675s. The interrupt flag never gets set. Example code (trying to trigger by pulling GP2 low):
:=
:=////////////////////////////////////////////////////////
:=//trying to make the INT external interrupt on GP2 work
:=//to switch state of a couple of LEDs on GP4,5
:=////////////////////////////////////////////////////////
:=#include <12f675.h>
:=#fuses INTRC_IO,PUT,NOWDT,NOPROTECT,NOMCLR, BROWNOUT
:=#use delay(clock=4000000)
:=//define IO pins
:=#bit gpio5 =0x05.5
:=#bit gpio4 =0x05.4
:=#bit gpio3 =0x05.3
:=#bit gpio2 =0x05.2
:=#bit gpio1 =0x05.1
:=#bit gpio0 =0x05.0
:=#use fast_io(a)
:=
:=#byte OSCCAL = 0x90
:=#rom 0x3ff = {0x3470} /// input the calibration code
:=#int_ext
:=void external_handler(void)
:={
:=gpio5=!gpio5; //instantly flip LEDs on external interrupt
:=gpio4=!gpio4;
:=delay_ms(100);
:=}
:=
:=#int_default
:=void default_isr(void)
:={}
:=
:=main()
:={
:=//setup i/o
:=set_tris_a(0b001100); //GP0,1,4,5 output; 2,3 input
:=gpio5=1; gpio4=0; gpio1=0; gpio0=0; //turn on LED on gp5
:=
:=//set timer0 not to use GP2
:=setup_counters(rtcc_internal, rtcc_div_2);
:=
:=//setup interrupts
:=enable_interrupts(int_ext);
:=ext_int_edge(h_to_l); //GP2 is pulled high with resistor
:=enable_interrupts(global);
:=
:=//loop and wait for interrupt
:=while(true)
:={
:=delay_ms(2500);
:=gpio5=!gpio5; //toggle LEDs just to show program is running
:=gpio4=!gpio4;
:=}
:=}
:=</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 10959
Ned Israelsen
Guest







Re: No external interrupt with PIC12F675??
PostPosted: Fri Jan 24, 2003 10:22 am     Reply with quote

I have removed the delay_ms call and bit flip from main() and the delay call from the isr. So, most of the time the program should be sitting in the while(true) loop doing nothing. Also tried different 12F675s. Still no interrupt. (Code works fine with properly-set-up RB port change interrupt on GP3.)


:=<font face="Courier New" size=-1>Remove your delay_ call from the ISR. ITs are disabled under execution of delay_ms() call in main() (so practically always is disabled).
:=
:=:=I have tried multiple methods to get an external interrupt to work with CPM programming PIC12F675s. The interrupt flag never gets set. Example code (trying to trigger by pulling GP2 low):
:=:=
:=:=////////////////////////////////////////////////////////
:=:=//trying to make the INT external interrupt on GP2 work
:=:=//to switch state of a couple of LEDs on GP4,5
:=:=////////////////////////////////////////////////////////
:=:=#include <12f675.h>
:=:=#fuses INTRC_IO,PUT,NOWDT,NOPROTECT,NOMCLR, BROWNOUT
:=:=#use delay(clock=4000000)
:=:=//define IO pins
:=:=#bit gpio5 =0x05.5
:=:=#bit gpio4 =0x05.4
:=:=#bit gpio3 =0x05.3
:=:=#bit gpio2 =0x05.2
:=:=#bit gpio1 =0x05.1
:=:=#bit gpio0 =0x05.0
:=:=#use fast_io(a)
:=:=
:=:=#byte OSCCAL = 0x90
:=:=#rom 0x3ff = {0x3470} /// input the calibration code
:=:=#int_ext
:=:=void external_handler(void)
:=:={
:=:=gpio5=!gpio5; //instantly flip LEDs on external interrupt
:=:=gpio4=!gpio4;
:=:=delay_ms(100);
:=:=}
:=:=
:=:=#int_default
:=:=void default_isr(void)
:=:={}
:=:=
:=:=main()
:=:={
:=:=//setup i/o
:=:=set_tris_a(0b001100); //GP0,1,4,5 output; 2,3 input
:=:=gpio5=1; gpio4=0; gpio1=0; gpio0=0; //turn on LED on gp5
:=:=
:=:=//set timer0 not to use GP2
:=:=setup_counters(rtcc_internal, rtcc_div_2);
:=:=
:=:=//setup interrupts
:=:=enable_interrupts(int_ext);
:=:=ext_int_edge(h_to_l); //GP2 is pulled high with resistor
:=:=enable_interrupts(global);
:=:=
:=:=//loop and wait for interrupt
:=:=while(true)
:=:={
:=:=delay_ms(2500);
:=:=gpio5=!gpio5; //toggle LEDs just to show program is running
:=:=gpio4=!gpio4;
:=:=}
:=:=}
:=:=</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 10969
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: No external interrupt with PIC12F675??
PostPosted: Fri Jan 24, 2003 1:00 pm     Reply with quote

:=I have tried multiple methods to get an external interrupt to work with CPM programming PIC12F675s. The interrupt flag never gets set.
------------------------------------------------------
I think the start-up code inserted by the compiler
may not be correct. Try doing the following:

Insert these lines above main():

#byte ADCON0 = 0x1F
#byte ANSEL = 0x9F
#byte CMCON = 0x19


Insert these lines at the very beginning of main():

ADCON0 = 0; // ADC off
ANSEL = 0; // GPIO pins 0,1,2 and 4 set to all digital
CMCON = 7; // Comparators off

See if that helps.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10971
Ned Israelsen
Guest







Re: No external interrupt with PIC12F675??
PostPosted: Fri Jan 24, 2003 8:31 pm     Reply with quote

:=:=I have tried multiple methods to get an external interrupt to work with CPM programming PIC12F675s. The interrupt flag never gets set.
:=------------------------------------------------------
:=I think the start-up code inserted by the compiler
:=may not be correct. Try doing the following:
:=
:=Insert these lines above main():
:=
:=#byte ADCON0 = 0x1F
:=#byte ANSEL = 0x9F
:=#byte CMCON = 0x19
:=
:=
:=Insert these lines at the very beginning of main():
:=
:=ADCON0 = 0; // ADC off
:=ANSEL = 0; // GPIO pins 0,1,2 and 4 set to all digital
:=CMCON = 7; // Comparators off
:=
:=See if that helps.

Yep. That fixed it! Thanks much!!
___________________________
This message was ported from CCS's old forum
Original Post ID: 10986
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