View previous topic :: View next topic |
Author |
Message |
rfjhh
Joined: 31 Mar 2011 Posts: 51 Location: Mexico
|
PortB interrupts and definition of edge |
Posted: Tue Feb 23, 2016 9:56 am |
|
|
I'm doing a program using port B interrupts (PIC16F887). If enable_interrupts use (INT_RB4 | H_TO_L); I have no problems, the bits of the corresponding IOCB register are established and the interrupt is enabled. However, if use L_TO_H, the corresponding bits in the IOCB are not set and the interrupt is not enabled.
The code is as follows:
Code: |
void main()
{
int8 i = 0,dum;
set_tris_a(0xff);
set_tris_b(0xf0);
setup_oscillator(OSC_8MHZ);
lcd_init();
setup_adc(ADC_CLOCK_INTERNAL);
SETUP_ADC_PORTS(sAN0);
/*Habilito interrupciones en PuertoB para entrada de teclado*/
enable_interrupts(GLOBAL); // INTCON<7:6>
enable_interrupts(INT_RB4 | L_TO_H); // INTCON<3>, IOCB<4>
enable_interrupts(INT_RB5 | L_TO_H); // INTCON<3>, IOCB<5>
enable_interrupts(INT_RB6 | L_TO_H); // INTCON<3>, IOCB<6>
enable_interrupts(INT_RB7 | L_TO_H); // INTCON<3>, IOCB<7>
enable_interrupts(GLOBAL); // INTCON<7:6>
for(;;)
{
dum = 0;
if(i==3)
i = 0;
else
i++;
output_b(fila[i]);
lcd_gotoxy(1,1);
printf(lcd_putc, "%2Lu", t_data);
}
}
|
What's going on? What can I do?
I am looking forward to your response.
Cheers
Ricardo Hernandez |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Tue Feb 23, 2016 10:01 am |
|
|
INT_RB does not work like this.
H_TO_L, is for INT_EXT _only_. Look at the data sheet. Look at the include file.
Quote: |
// Constants used in EXT_INT_EDGE() are:
#define L_TO_H 0x40
#define H_TO_L 0
|
INT_RB, is an interrupt on _change_. All changes. No direction control on this chip. |
|
|
rfjhh
Joined: 31 Mar 2011 Posts: 51 Location: Mexico
|
|
Posted: Tue Feb 23, 2016 12:57 pm |
|
|
Thanks |
|
|
|