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 support@ccsinfo.com

interruptions questions

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



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

interruptions questions
PostPosted: Wed Oct 21, 2009 3:49 pm     Reply with quote

Hi

Is possible on PIC18F252 I use serial interrupts and on the same program RB interrupts?

I like know when receive information from Serial Port and when Button is press.

Best regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 21, 2009 4:22 pm     Reply with quote

Quote:
Is possible on PIC18F252 I use serial interrupts and on the same
program RB interrupts?

Yes.

Quote:

I like know when receive information from Serial Port and when Button is press.

See these CCS example files:
Quote:
c:\program files\picc\examples\ex_pbutt.c
c:\program files\picc\examples\ex_sisr.c
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

PostPosted: Wed Oct 21, 2009 4:27 pm     Reply with quote

hi

Thanks PCM Programmer

One more question... is possible I have interrupts only on pins RC0 and RC1?

Best regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 21, 2009 4:39 pm     Reply with quote

Please read the 18F252 data sheet. There are no interrupts available
on pins C0 and C1.

If you actually mean pins B4 and B5, the answer is no. The 18F452
does not have the ability to individually enable #int_rb interrupts on
pins B4 to B7. They are either all on, or all off.
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

PostPosted: Wed Oct 21, 2009 4:50 pm     Reply with quote

hi

I think an virtual interrupt, but if don't have this option, I change my circuit...

best regards
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

PostPosted: Mon Oct 26, 2009 1:13 pm     Reply with quote

Hi

I read the datasheet but I have one question... if I enable #int_rb I only have interrupts on ports B0,B1,B2, correct? others B3 - B7 I can user normal I/O?

best regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 26, 2009 2:21 pm     Reply with quote

#int_rb is used for Interrupt-on-Change interrupts on pins B4-B7.

#int_ext is used for External interrupts on pin B0
#int_ext1 is for pin B1
#int_ext2 is for pin B2
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

PostPosted: Mon Oct 26, 2009 3:30 pm     Reply with quote

hi

For example, if I have this code:
Code:

#include <18F252.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,BROWNOUT,STVREN
#use delay(clock=20000000)
#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

#int_ext
void int_rb0()
{
printf("PIN RB0 PRESS\n\r");
}

void main()
{
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);


while(1)
{
printf("wait for keypress\n\r");
delay_ms(2000);
}
}


I only have interrupts on pin RB0 and other pins is normal I/O, correct?

best regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 26, 2009 3:36 pm     Reply with quote

Quote:

I only have interrupts on pin RB0 and other pins is normal I/O, correct?

That is correct.
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

PostPosted: Mon Oct 26, 2009 5:10 pm     Reply with quote

Hi

Interrupts work with negative logic? I have an pull-up connect on pin RB0 and I need detect when this pin go to "0"... this is possible or I need use an inverter?

This signal is output of an comparator lm311...

best regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 26, 2009 5:27 pm     Reply with quote

The answer is in the manual. Download it.
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
Look on page 170 in the Acrobat reader, in this section:
Quote:
ext_int_edge( )
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

PostPosted: Mon Oct 26, 2009 5:43 pm     Reply with quote

hi

Code:

#int_ext
void int_rb0()
{
   //detect when pin RB0 go to zero...
}


#int_rda
void rda_isr(void)
{
   .................
}


void main()
{
int8 speed1,btn1,btn2,btn3,btn4;

   enable_interrupts(GLOBAL);
   ext_int_edge(H_TO_L);      // init interrupt triggering for button press
   enable_interrupts(INT_EXT);
   enable_interrupts(INT_RDA);     
   setup_timer_2(T2_DIV_BY_1, 255, 1);
   setup_ccp1(CCP_PWM);
   set_pwm1_duty(0);  //0 até 255

while(1)
   {
   ..................
   }
}

This configuration stay correct to detect pulses when go to zero?

best regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 26, 2009 5:53 pm     Reply with quote

It should execute the #int_ext routine when you get a falling edge
on the RB0 pin.
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

PostPosted: Mon Oct 26, 2009 5:56 pm     Reply with quote

hi

when you tell #int_ext routine do you mean which it go execute function void int_rb0() when pin go to zero correct?

PS: sorry my ingles...

best regards PCM
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 26, 2009 6:59 pm     Reply with quote

Yes, I just told you that.

I've had enough for today. I don't want to answer any more questions.
Someone else can do it.
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