antriksh
Newbie level 6
- Joined
- Aug 3, 2013
- Messages
- 13
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 3
- Activity points
- 93
i have used a lcd to infce with pic 16f688 . but after a perticular code if add any thing it will effect on lcd and chage there orentation of text.
code as give below :
becuase idont want any thing to disply on lcd at this point of time ... it is working but in normal case some text chnge on lcd . and i am noticing in only this bit code RAM is 78% full alredy
code as give below :
Code:
// LCD module connections
sbit LCD_RS at RC5_bit;
sbit LCD_EN at RC2_bit;
sbit LCD_D4 at RC1_bit;
sbit LCD_D5 at RC0_bit;
sbit LCD_D6 at RA2_bit;
sbit LCD_D7 at RA1_bit;
sbit LCD_RS_Direction at TRISC5_bit;
sbit LCD_EN_Direction at TRISC2_bit;
sbit LCD_D4_Direction at TRISC1_bit;
sbit LCD_D5_Direction at TRISC0_bit;
sbit LCD_D6_Direction at TRISA2_bit;
sbit LCD_D7_Direction at TRISA1_bit;
// End LCD module connections
unsigned int displaycount,OPVOL,BATTVOL,CTVOL = 0 ;
unsigned char count,flag = 0 ;
char *adc= "00.0";
char *adc1= "000";
void Display_adc(unsigned int adc2write){
adc[0] = (adc2write/100) + 48; // Extract hundreds digit
adc[1] = (adc2write/10)%10 + 48; // Extract tens digit
adc[3] = adc2write%10 + 48; // Extract ones digit
}
void Display2_adc(unsigned int adc12write){
adc1[0] = (adc12write/100) + 48; // Extract hundreds digit
adc1[1] = (adc12write/10)%10 + 48; // Extract tens digit
adc1[2] = adc12write%10 + 48; // Extract ones digit
}
void InitTimer0(){
OPTION_REG = 0x87;
TMR0 = 100;
INTCON = 0xA0;
}
void Interrupt() // 20 ms timer intruppt
{
if (TMR0IF_bit)
{
TMR0IF_bit = 0;
TMR0 = 100;
displaycount++;
count++;
}
}
void main() {
TRISC = 0b11111111; // Make Rc0 input
TRISA = 0b11111111; // Make RA0 input
PORTA = 0X00 ;
ANSEL = 0b10001001;
//ADCON1 = 0x00;
CMCON0 = 0x07 ; // Disbale comparators
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // CLEAR display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
ADC_Init();
InitTimer0();
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
while(1)
{
OPVOL = ADC_Read(3); // Get outpt voltage
CTVOL = ADC_Read(0); // Get load current
BATTVOL = ADC_Read(7); // Get batt voltage
if( displaycount == 1 || displaycount == 25 || displaycount == 50 || displaycount == 99) // output voltage display
{
if (RC4_bit == 1)
{
Lcd_out(1,1," LOAD ON MAINS ");
}
else
{
Lcd_out(1,1," LOAD ON BATT " );
}
Lcd_out(2,1,"OUTPUT VAC= V");
Display2_adc(OPVOL);
Lcd_out(2,12,adc1);
}
if(displaycount == 100 || displaycount == 125 || displaycount == 150 || displaycount == 199) // load current display
{
Lcd_out(1,1," LOAD CURRENT ");
Lcd_out(2,1," AMP = A ");
Display_adc(CTVOL);
Lcd_Out(2,8,adc);
}
if(displaycount == 202 || displaycount == 225 || displaycount == 250 || displaycount == 299) // batt volt display
{
Lcd_out(1,1," BATTERY VOLTAGE" );
Lcd_out(2,1," VDC = V ");
Display_adc(BATTVOL);
Lcd_Out(2,7,adc);
}
if(displaycount >= 300)
{
displaycount = 0;
}
while(BATTVOL >= 600) // batt check
{
BATTVOL = ADC_Read(7);
Lcd_out(1,1," LOW BATTERY ");
Lcd_out(2,1,"RECHARGE BATTERY");
}
} // while end
}
??????????????????????????????????????????????????????
if i add this in main... LCD TEXT CHAGE AUTOMATICALY
????????????????????????????????????????????????????????
while (OPVOL >= 600) // batt check
{
OPVOL = ADC_Read(3);
Lcd_out(1,1," LOW BATTERY ");
Lcd_out(2,1,"RECHARGE BATTERY");
}
becuase idont want any thing to disply on lcd at this point of time ... it is working but in normal case some text chnge on lcd . and i am noticing in only this bit code RAM is 78% full alredy
Last edited by a moderator: