CCS :: View topic - impossible to use RB0 as interrupt

http://ccsinfo.com/forum/viewtopic.php?t=27889&highlight=inte...

FAQ

Forum Help Profile

Official CCS Support

Search

Register Log in

Log in to check your private messages

impossible to use RB0 as interrupt
CCS Forum Index -> General CCS C Discussion View previous topic :: View next topic Author doudlap impossible to use RB0 as interrupt
Posted: Thu Aug 10, 2006 1:19 pm Joined: 10 Aug 2006 Posts: 7

Message

With the code below, I have a problem, I never pass into my interrupt fonction. Do you know my problem ?

-------------------------------------------------------Code: #device adc=8 #FUSES NOWDT //No Watch Dog Timer #FUSES #use delay(clock=16000000) #use rs232(baud=9600,parity=N,xmit=PIN_B5,rcv=PIN_B2,bits=9) //Global declares static int x; #int_ext void INTRB0(void);

main() { ext_int_edge(H_TO_L); enable_interrupts(INT_EXT); clear_interrupt(INT_EXT); // Add this line enable_interrupts(GLOBAL); while(true) { printf("%d",x); delay_ms(1000); } }

#INT_EXT void INTRB0() { x = 999; printf("%d",x); delay_ms(500); } rnielsen
Posted: Thu Aug 10, 2006 1:25 pm

Joined: 23 Sep 2003

1 от 6

01.3.2007 г. 10:20

CCS :: View topic - impossible to use RB0 as interrupt

http://ccsinfo.com/forum/viewtopic.php?t=27889&highlight=inte...

Posts: 430 Location: Utah

Try moving the body of the ISR _above_ main() and don't declare it as a function. Ronald ________________ You know you're old when you can remember 'Five and Dime' stores.

doudlap

Posted: Thu Aug 10, 2006 2:06 pm

Joined: 10 Aug 2006 Posts: 7

Ok, I have change but my value x no change. Have you got an another idea ?

Code: #FUSES NOWDT //No Watch Dog Timer #FUSES #use delay(clock=16000000) #use rs232(baud=9600,parity=N,xmit=PIN_B5,rcv=PIN_B2,bits=9)

//Global declares static int x; #int_EXT EXT_isr() { x = 999; printf("%d",x); delay_ms(2500); }

main() { ext_int_edge(L_TO_H); enable_interrupts(INT_EXT); clear_interrupt(INT_EXT); // Add this line enable_interrupts(GLOBAL); while(true) { printf("%d",x); delay_ms(1000); } }

thank for all doudlap
PCM programmer
Posted: Thu Aug 10, 2006 2:14 pm

Joined: 06 Sep 2003 Posts: 6775

See this thread: http://www.ccsinfo.com/forum/viewtopic.php?t=27868

doudlap

Posted: Thu Aug 10, 2006 3:33 pm

Joined: 10 Aug 2006 Posts: 7

okay I have review my code but no success. question : The pin rb0 of the pic 16f88 will be interrupted by this interruption ?

My new code tested is :
Code:

2 от 6

01.3.2007 г. 10:20

CCS :: View topic - impossible to use RB0 as interrupt

http://ccsinfo.com/forum/viewtopic.php?t=27889&highlight=inte...

#include <16F88.h> #device adc=8 #FUSES NOWDT //No Watch Dog Timer #FUSES #use delay(clock=16000000)

#int_EXT EXT_isr() { output_high(PIN_B7); } #use delay(clock=16000000) main() { output_low(pin_b7); enable_interrupts(INT_EXT); enable_interrupts(GLOBAL); while(true) { } } rnielsen

Posted: Thu Aug 10, 2006 3:36 pm

Joined: 23 Sep 2003 Posts: 430 Location: Utah

Add NOLVP to your Fuses. There might be other Fuses that should be inserted as well. Don't use delay() or printf() in an ISR. Are you sure you should be using 9bits in your RS232? You don't need the clear_interrupt() command. You're trying to stuff a value of 999 into a variable that can only accomodate a max of 255. Have something like: x++; in your ISR to see if it is changing when an interrupt happens. You don't need 'static' when you declare a Global variable. Is this the entire program or have you edited things out just to post it? It won't work as you've posted it because you don't have your oscillator Fuse in there among some other setup commands. Does the program even send anything to the RS232 or does it just sit there acting dead? If it's dead then you definately don't have all of the Fuses and setup commands that are needed. Post a _complete_ program including all Fuses and setup commands. Ronald

jspencer

Posted: Thu Aug 10, 2006 3:50 pm

Joined: 22 Dec 2003 Posts: 59 Location: Boise, ID USA

First thing I would try is to use the project wizard as it will help you setup your project with the options that you need. This is what I got from the project wizard with just a couple of lines that I added.
Code:

3 от 6

01.3.2007 г. 10:20

CCS :: View topic - impossible to use RB0 as interrupt

http://ccsinfo.com/forum/viewtopic.php?t=27889&highlight=inte...

#include <16F88.h> #device adc=8 #FUSES NOWDT //No Watch Dog Timer #FUSES HS //High speed Osc (> 4mhz) #FUSES PUT //Power Up Timer #FUSES MCLR //Master Clear pin enabled #FUSES NOBROWNOUT //No brownout reset #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O #FUSES NOCPD //No EE protection #FUSES NOWRT //Program memory not write protected #FUSES NODEBUG //No Debug mode for ICD #FUSES NOPROTECT //Code not protected from reading #FUSES NOFCMEN //Fail-safe clock monitor disabled #FUSES NOIESO //Internal External Switch Over mode disabled #use delay(clock=16000000) int8 b_flag; #int_EXT EXT_isr() { b_flag = TRUE; }

void main() { setup_adc_ports(NO_ANALOGS|VSS_VDD); setup_adc(ADC_OFF); setup_spi(FALSE); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE); enable_interrupts(INT_EXT); enable_interrupts(GLOBAL); setup_oscillator(False); ext_int_edge(H_TO_L); // or L_TO_H output_low(PIN_B7); b_flag = FALSE; while (1) { if (b_flag) { output_high(PIN_B7); delay_ms(2000); // reset to catch next interrupt output_low(PIN_B7); b_flag = FALSE; } } }

Looking at your code you are definitely missing a fuse setting for your crystal/oscillator. I'm not sure that your pic is even running.
doudlap
Posted: Thu Aug 10, 2006 3:54 pm

Joined: 10 Aug 2006 Posts: 7

I haven't use CCS before, so I'am sorry for this problem. It's the full program. and I search to use the pin B0 as an interrupt because when I will find the solution, i will use all pin of port A and B. but, actually I'm testing the solution with the software proteus. And can use interrupt whit RB4 to RB7. So i think is a problem in my source code. in the last code, I have delete the delay and the Rs232. but the interruption is never call.

4 от 6

01.3.2007 г. 10:20

CCS :: View topic - impossible to use RB0 as interrupt

http://ccsinfo.com/forum/viewtopic.php?t=27889&highlight=inte...

doudlap

Posted: Thu Aug 10, 2006 4:07 pm

Joined: 10 Aug 2006 Posts: 7

jspencer, before testing lots of possibilites, I used the wizard but no result. I will test your source code in a real pic and not b the software PROTEUS Because I copy/paste your code but th interrupt no work I don't know why. oh I have made a new test. I take a 16f876 and the code work perfectly. So why with a 16f88 the result no work ? probebly the software proteus no work well why the pic 16f88 ??

doudlap

Posted: Fri Aug 11, 2006 12:23 am

Joined: 10 Aug 2006 Posts: 7

nobody have an idea ?

ckielstra

Posted: Fri Aug 11, 2006 1:42 am

Joined: 18 Mar 2004 Posts: 1334 Location: The Netherlands

doudlap wrote: nobody have an idea ?

You said you were going to try on real hardware instead of in the Proteus simulator. How did this test go? Which version number of the CCS compiler are you using? (see the top of the *.lst file to find this number, it looks like 3.xxx).
doudlap
Posted: Fri Aug 11, 2006 4:54 am

Joined: 10 Aug 2006 Posts: 7

my version is 3.249 t's possible that come of my version ?

Christophe

Posted: Fri Aug 11, 2006 6:01 am

Joined: 10 May 2005 Posts: 248 Location: Varsenare, Belgium

1. don't use delay_ms ( ) function inside ISR (). It makes your software hang, you can find an explanation of that using the forum search function 2. Measure with a scope on pin RB0 of your PIC. Is it wired OK ? Measure if you have a transition. Should be on PIN 6 of your IC. http://ww1.microchip.com/downloads/en/DeviceDoc/30487c.pdf 3. Your PIC is dead? Try to implement jspencer's code gl
Display posts from previous: All Posts

Oldest First

Go
All times are GMT - 6 Hours

CCS Forum Index -> General CCS C Discussion Page 1 of 1

Jump to: General CCS C Discussion

Go

You can post new topics in this forum You can reply to topics in this forum

5 от 6

01.3.2007 г. 10:20

CCS :: View topic - impossible to use RB0 as interrupt

http://ccsinfo.com/forum/viewtopic.php?t=27889&highlight=inte...

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

6 от 6

01.3.2007 г. 10:20

Sign up to vote on this title
UsefulNot useful