View previous topic :: View next topic |
Author |
Message |
YulL
Joined: 29 Sep 2004 Posts: 39 Location: Paris (France)
|
Problem with timer interrupt (bug?) |
Posted: Fri Oct 01, 2004 3:40 am |
|
|
Hi everybody,
I'm trying to implement a button that light up my LCD screen (HD44780) with the LED+ Pin, on a rising edge of that button. It is just like a time watch when you push the "light" button : it smoothly lights up, stay lighted for a few seconds, and the it lights down smoothly.
So I will use the RBO/INT Pin of the PIC16F873 in order to detect a rising edge of my switch and to produce an interrupt in my software in order to light up my LCD...
The problem is that the RBO/INT Pin is already used by the lcd.c driver...
Could someone help me for modify this allocation and put the ENABLE RB0 Pin in the RB3 Pin that is not used?
Thanks for your kind support
Last edited by YulL on Fri Oct 01, 2004 9:19 am; edited 1 time in total |
|
|
YulL
Joined: 29 Sep 2004 Posts: 39 Location: Paris (France)
|
|
Posted: Fri Oct 01, 2004 4:14 am |
|
|
OK I've found how to do this by modifying my lcd.c driver :
struct lcd_pin_map { // This structure is overlayed
boolean unused; // on to an I/O port to gain
boolean rs; // access to the LCD pins.
boolean rw; // The bits are allocated from
boolean enable; // low order up. ENABLE will
int data : 4; // be pin B3.
} lcd;
And it works |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
|
YulL
Joined: 29 Sep 2004 Posts: 39 Location: Paris (France)
|
|
Posted: Fri Oct 01, 2004 9:21 am |
|
|
Thanks for your reply.
I have another problem now, here is the code :
#int_EXT
EXT_isr()
{
output_high(LIGHT);
set_timer1(0xFC4F);
enable_interrupts(INT_TIMER1);
}
#int_TIMER1
TIMER1_isr()
{
output_low(LIGHT);
}
void main()
{
int16 demo;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_counters(RTCC_INTERNAL,RTCC_DIV_256);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
setup_timer_2(T2_DISABLED,0,1);
set_tris_a (0x00);
set_tris_b (0x01);
output_low(PIN_B0);
set_tris_c (0xBF); //RC7 Input & RC6 Output
enable_interrupts(INT_EXT);
ext_int_edge( L_TO_H ); // Sets up EXT
enable_interrupts(global);
output_low(LED0);
output_low(LED1);
demo=0;
lcd_init();
delay_ms( 20 );
printf(lcd_putc, "\fAIRLINK 2080\nGlobalSys\n");
delay_ms( 3000 );
lcd_putc("\f");
printf("Press any key to begin\n\r");
getc();
while(1)
{
printf(lcd_putc,"\f%ld s",demo);
demo++;
output_low(LED0);
output_low(LED1);
delay_ms( 1000 );
printf(lcd_putc,"\f%ld s",demo);
demo++;
output_low(LED0);
output_high(LED1);
delay_ms( 1000 );
printf(lcd_putc,"\f%ld s",demo);
demo++;
output_high(LED0);
output_low(LED1);
delay_ms( 1000 );
printf(lcd_putc,"\f%ld s",demo);
demo++;
output_high(LED0);
output_high(LED1);
delay_ms( 1000 );
}
}
My interrupt works very well before my while(1), but when I'm in, after 4 or 5 five interrupts with timer 0 or timer 1, The RB0/INT is always +4.5V...
Bug???? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Fri Oct 01, 2004 11:08 am |
|
|
Post the #defines and the device and fuse settings. Also, use the code button to post the code. It makes it easier to read. |
|
|
YulL
Joined: 29 Sep 2004 Posts: 39 Location: Paris (France)
|
|
Posted: Mon Oct 04, 2004 1:21 am |
|
|
Here it is :
#include "C:\Documents and Settings\GLOBALSYS\Mes documents\PCW TEST\TEST.h"
#include <stdio.h>
#include <lcd.c>
#int_EXT
EXT_isr()
{
output_high(LIGHT);
set_timer1(0xFC4F);
enable_interrupts(INT_TIMER1);
}
#int_TIMER1
TIMER1_isr()
{
output_low(LIGHT);
}
void main()
{
...
}
It's strange, I can't understand why it doesn't work...
Thanks for the reply |
|
|
|