View previous topic :: View next topic |
Author |
Message |
filjoa
Joined: 04 May 2008 Posts: 260
|
interruptions questions |
Posted: Wed Oct 21, 2009 3:49 pm |
|
|
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
|
|
Posted: Wed Oct 21, 2009 4:22 pm |
|
|
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
|
|
Posted: Wed Oct 21, 2009 4:27 pm |
|
|
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
|
|
Posted: Wed Oct 21, 2009 4:39 pm |
|
|
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
|
|
Posted: Wed Oct 21, 2009 4:50 pm |
|
|
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
|
|
Posted: Mon Oct 26, 2009 1:13 pm |
|
|
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
|
|
Posted: Mon Oct 26, 2009 2:21 pm |
|
|
#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
|
|
Posted: Mon Oct 26, 2009 3:30 pm |
|
|
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
|
|
Posted: Mon Oct 26, 2009 3:36 pm |
|
|
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
|
|
Posted: Mon Oct 26, 2009 5:10 pm |
|
|
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
|
|
|
filjoa
Joined: 04 May 2008 Posts: 260
|
|
Posted: Mon Oct 26, 2009 5:43 pm |
|
|
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
|
|
Posted: Mon Oct 26, 2009 5:53 pm |
|
|
It should execute the #int_ext routine when you get a falling edge
on the RB0 pin. |
|
|
filjoa
Joined: 04 May 2008 Posts: 260
|
|
Posted: Mon Oct 26, 2009 5:56 pm |
|
|
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
|
|
Posted: Mon Oct 26, 2009 6:59 pm |
|
|
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. |
|
|
|