deepakomanna
Joined: 06 Mar 2007 Posts: 92 Location: Pune,India
|
help need to display numbers on static LCD |
Posted: Mon Dec 31, 2007 7:48 am |
|
|
Dear Sir,
here i am using 16f913, MPLAB 7.5 Ver. & CCS PCM C Compiler, Version 3.249, 34534.
In this i am displaying numbers from rightmost side.The number is incrementing in every 1 sec.Also I have to blink a symbol as like "Dumbbell shped" in every 1 sec. The symbol is at left side. Here i/p is frequency (297 Hz)which is connected at pin no 16 (RC5).In the ccp1 interrupt i am incrementing 1 variable to count 1 sec. Once it reaches to 1 sec count then it will compliment the flag "BLINK_DUMBEL". this flag is used for blinking the symbol. & increment the number. which will display on Static LCD.
The number is incrementing properly but the Symbol is not blinking in every 1 sec. sometimes it wll blnk & sometimes not blink.
Here is my code,Plz help.
Code: | #include<16F913.h>
#fuses INTRC_IO,NOWDT,PUT,NOMCLR,NOPROTECT,NOCPD,BROWNOUT,NOIESO,NOFCMEN //external MCLR bcz of MPLAB ICD2
#use delay(clock=8000000)
/////////////////////////////////////////////////////////////////////////////////////////
// LCD Configuration //
/////////////////////////////////////////////////////////////////////////////////////////
// Digit segments A B C D E F G DP
// b7 b6 b5 b4 b3 b2 b1 b0
#define DIGIT1 COM0+0, COM0+1, COM2+1, COM3+0, COM2+0, COM1+0, COM1+1, COM3+3 // DISPALYS FROM RIGHT SIDE
#define DIGIT2 COM0+2, COM0+3, COM2+3, COM3+2, COM2+2, COM1+2, COM1+3 // DISPALYS FROM RIGHT SIDE
#define DIGIT3 COM0+4, COM0+5, COM2+5, COM3+4, COM2+4, COM1+4, COM1+5 // DISPALYS FROM RIGHT SIDE
#define DIGIT4 COM0+6, COM0+7, COM2+7, COM3+6, COM2+6, COM1+6, COM1+7 // DISPALYS FROM RIGHT SIDE
#define DIGIT5 COM0+8, COM0+9, COM2+9, COM3+8, COM2+8, COM1+8, COM1+9 // DISPALYS FROM RIGHT SIDE
#define DIGIT6 COM0+13, COM0+11, COM2+11, COM3+13, COM2+13, COM1+13, COM1+11 // DISPALYS FROM RIGHT SIDE
#define DIGIT7 COM0+12, COM0+14, COM2+14, COM3+12, COM2+12, COM1+12, COM1+14 // DISPALYS FROM RIGHT SIDE#define VLCD_ENABLE 0x10
#define DUMBEL COM3+14
#define VLCD_ENABLE 0x10
//character 0 1 2 3 4 5 6 7 8 9
byte const Digit_Map[10] = {0xFD,0x61,0xDB,0xF3,0x67,0xB7,0xBF,0xE1,0xFF,0xF7};
byte lcd_pos;
byte segments;
void init_CPU();
int32 number;
int16 sec_counter;
int1 BLINK_DUMBEL ; // this flag for blinking the DUMBEL SYMBOL
void lcd_putc(char c)
{
if(c=='\f')
lcd_pos=0;
else {
if((c>='0')&&(c<='9'))
{
segments=Digit_Map[c-'0'];
}
else
segments=0;
switch(lcd_pos)
{
case 1: lcd_symbol(segments,DIGIT7); break; // fill 1s place
case 2: lcd_symbol(segments,DIGIT6); break; // fill 1s place
case 3: lcd_symbol(segments,DIGIT5); break; // fill 10s place
case 4: lcd_symbol(segments,DIGIT4); break; // fill 100s place
case 5 : lcd_symbol(segments,DIGIT3); break; // fill 1000s place
case 6 :
if(number<10)
segments = Digit_Map[0];
lcd_symbol(segments,DIGIT2); break; // fill 10000splace
case 7 :
if(BLINK_DUMBEL == 1)
lcd_symbol(segments,DUMBEL); // fill 100000s place
else
lcd_symbol(segments,0); // fill 100000s place
lcd_symbol(segments,DIGIT1); // fill 100000s place
break;
}
}
lcd_pos++;
}
#int_ccp1
void ccp1_isr(void)
{
sec_counter++;
if(sec_counter >=298) // 1sec == 298 count
{
BLINK_DUMBEL =~BLINK_DUMBEL; // compliment flag for DUMBEL SYMBOL.
// if(BLINK_DUMBEL == 1)
// lcd_symbol(segments,DUMBEL); // fill 100000s place
sec_counter = 0;
number++;
if(number == 999999)
number = 0;
}
}
void init_CPU()
{
/************** PORT SETTINGS ****************/
PORT_B_PULLUPS(0X00);
SET_TRIS_A(0XC0); //External Oscillator i/p OSC1 & OSC2
SET_TRIS_B(0X00);
SET_TRIS_C(0X27); //VLCD 1,2,3 i/p,FREQ i/p @ Pin no 16.
SET_TRIS_E(0X08); // RE3 i/p for programming the device.
/*************** LCD SETTINGS ********************/
SETUP_LCD( LCD_MUX14 |LCD_INTRC|VLCD_ENABLE, 2);
/**************** COMPARATOR SETTINGS ***************/
SETUP_COMPARATOR(NC_NC_NC_NC);
/**************** INTERRUPT SETTINGS *****************/
ENABLE_INTERRUPTS(GLOBAL);
set_timer1(0);
setup_ccp1(CCP_CAPTURE_RE); //Capture on rising edge
clear_interrupt(INT_CCP1);
enable_interrupts(INT_CCP1);
setup_timer_1(T1_EXTERNAL | T1_DIV_BY_1 | T1_CLK_OUT);
}
void main()
{
init_CPU();
number = 0;
while(TRUE)
{
printf(lcd_putc,"\f%7lu",number);
}
}
|
_________________ Thank You,
With Best Regards,
Deepak. |
|