Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

interrupt on pin RB0 incre ment the counter on lcd

Status
Not open for further replies.

ankur basal

Newbie level 4
Joined
Apr 9, 2011
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,360
hello
i have write program i n c
to display string but i wanna display to count button press on RBo on lcd any buddy help me my is it
#include<htc.h>
#include<pic.h>
#define EN RC7 // 24
#define RW RC6 // 25
#define RS RC5 // 26
#define DB0 RD0
#define DB1 RD1
#define DB2 RD2
#define DB3 RD3
#define DB4 RD4
#define DB5 RD5
#define DB6 RD6
#define DB7 RD7
#define Data PORTD
#ifndef _XTAL_FREQ
#define _XTAL_FREQ 4000000
#endif
char count=0;
char x;
__CONFIG(0x3F79);


void init_LCD()
{
int i=1, j=1;

TRISA=0x00;
TRISB=0x00;
TRISC=0x01;
TRISD=0x00;
TRISE=0x00;
PORTA=0x00;
PORTB=0x00;
PORTC=0x00;
PORTD=0x00;
PORTE=0x00;
TMR1ON=0;


for(j=1;j<=3;j++)
{
RS=0;
RW=0;
Data=0x38;
EN=1;
asm("nop");
EN=0;
for(i=1;i<1000;i++)
{
__delay_us(20);
}
}

RS=0;
RW=0;
Data=0x0C;
EN=1;
asm("nop");
EN=0;
for(i=1;i<1000;i++)
{ __delay_us(5);
}

RS=0;
RW=0;
Data=0x01;
EN=1;
asm("nop");
EN=0;
for(i=1;i<1000;i++)
{ __delay_us(5);
}

RS=0;
RW=0;
Data=0x06;
EN=1;
asm("nop");
EN=0;
for(i=1;i<1000;i++)
{ __delay_us(5);
}

RS=0;
RW=0;
Data=0x80;
EN=1;
asm("nop");
EN=0;
for(i=1;i<1000;i++)
{ __delay_us(5);
}

}


void display(char x)
{
int i=1;
RW=0;
RS=1;
Data=x;
EN=1;
asm("nop");
EN=0;
for(i=1;i<1000;i++)
{ __delay_us(20);
}

}

void LCD_sendstring(unsigned char *var)
{
while(*var) //till string ends
display(*var++); //send characters one by one
}

void main()
{
unsigned char msg1[] ="Traffic Density";
for(int i=1;i<50;i++)
{
__delay_ms(1);
}

init_LCD();
RC0=~RC0;
LCD_sendstring(msg1);
while(1)
{
}

}
 

to enable RB0 interrupt ,

TRISB0=1;//dont use TRISB=0
INTE=1;
GIE=1;

Now make a function ,
void interrupt xyz()
{
INTF=0;



}

---------- Post added at 14:12 ---------- Previous post was at 14:09 ----------

also set or clear the INTEDG bit in OPTION REGISTER to set interrupt on rising edge or falling edge respectively...

---------- Post added at 14:22 ---------- Previous post was at 14:12 ----------

You should also consider the switch debounce effect while using external interrupts via pushbuttons...To avoide it you need to stay in ISR untill the debounce effect vanishes. Google it and fine the required delay...
 

Thanks friend
i have set it but how to set option register and how to display counter on lcd plz help me
 

increment an int in RB0 interrupt service routine. (say count++;)
Then in main program introduce a code to convert the count to corresponding decimal digits and send the ascii of the digits to LCD one by one , from the MSB to LSB. Before that set the LCD cursor position. (say 0x80)

Now i think you can do it...You mean you want the exact code?
 

I have count encoder pulse on interrupt RB0 here.
You may change RB0 input to count push button pressed.
 

hi vinod
can u tell me how to Creat digital clock with using ds 1307 ic i wanna make clock with increment& decrement button hr min sec
plz tell me
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top