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

Problem with timer interrupt (bug?)

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



Joined: 29 Sep 2004
Posts: 39
Location: Paris (France)

View user's profile Send private message

Problem with timer interrupt (bug?)
PostPosted: Fri Oct 01, 2004 3:40 am     Reply with quote

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)

View user's profile Send private message

PostPosted: Fri Oct 01, 2004 4:14 am     Reply with quote

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 Laughing
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Oct 01, 2004 5:55 am     Reply with quote

I rewrote the lcd.c driver to work with the picdem2 plus board. This new file allows you to change the pin assignments more easily. See this post for the code:

http://www.ccsinfo.com/forum/viewtopic.php?t=20182
YulL



Joined: 29 Sep 2004
Posts: 39
Location: Paris (France)

View user's profile Send private message

PostPosted: Fri Oct 01, 2004 9:21 am     Reply with quote

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...
Embarassed
Bug????
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Oct 01, 2004 11:08 am     Reply with quote

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)

View user's profile Send private message

PostPosted: Mon Oct 04, 2004 1:21 am     Reply with quote

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... Crying or Very sad

Thanks for the reply Cool
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