Thanks for ur reply
you r correctly understood but i have not initialized or using any other module on this PTB pin, i am using this for input(ptb6,7) and other ptb0-5 for output data and En, RS for lcd. i m doing nothing else i m sending u the code plz check where the problem is.
//Programm to display AC Voltage & Current/DC Voltage
//AC/DC Display Selection by jumper
//Voltage/Current range selection by jumpers
//onboard Reset/Mon8 connector
//PTB0-3 LCD Display data
//PTB4 Enable
//PTB5 RS
//PTB6-7Voltage range selection by jumper.
#include <hidef.h> /* for EnableInterrupts macro */
#include <MC68HC908QB8.h> /* include peripheral declarations */
//macro defination for PORTB out
#define setbit(A,B) A|=(1<<B)
#define clrbit(A,B) A&=~(1<<B)
void delay(unsigned int cycles)
{
unsigned int del;
for(del=0;del<cycles;del++);
}
void out(unsigned char lcd_data,unsigned char fl)
//fl 0 is command & 1 is data
{
// higher nibble 1st then lower nibble
unsigned char del;
PTB = (lcd_data & 0xF0)>>4;
if(fl == 1)
setbit(PTB,5); // rs = 1;
setbit(PTB,4); // en = 1;
for(del=0;del<25;del++);//some delay
clrbit(PTB,4); // en = 0;
PTB = lcd_data & 0x0F;
if(fl == 1)
setbit(PTB,5); // rs = 1;
setbit(PTB,4); // en = 1;
for(del=0;del<25;del++);//some delay
clrbit(PTB,4); // en = 0;
clrbit(PTB,5); // rs = 0;
fl = 0;
delay(300);
}
/*
unsigned int adc(unsigned char channel)
{
unsigned int adc_value;
ADCLK = 0x10;
ADSCR = channel;
delay();
while(!ADSCR_COCO);
adc_value = ADRH*256 + ADRL;
return ( adc_value );
}
*/
void main(void)
{
unsigned char var=0;
delay(100);//Some initial power on delay
CONFIG1=0x01; //disable COP
//initialisation
DDRB = 0x3F; // 0011 1111
PTB=0;//initially PTB out =0
PTBPUE=0x00; //00 00 0000 PULL UP Disabled.
//power up delay
delay(10000);//500msec approx
//main function
//initializing LCD
//out(0x30,0);//commands
//out(0x30,0);
//out(0x30,0);
out(0x20,0);
out(0x20,0);
out(0x28,0);
out(0x28,0);
out(0x0C,0);
out(0x06,0);
out(0x02,0);
out(0x01,0); //Clear display
while(1)
{
//1st line code
out(0x80,0);//Line 1 Character 1 (Position)
if ((PTB & 0x80)==128) out('D',1);//1 (if pin 7 PTB then DC Display
else out('A',1);//1
out('C',1);//2
out(' ',1);//3
out('V',1);//4
out('o',1);//5
out('l',1);//6
out('t',1);//7
out(' ',1);//8
out(' ',1);//9
out(' ',1);//10
out('0',1);//11
out('0',1);//12
out('0',1);//13
out('.',1);//14
out('0',1);//15
out('V',1);//16
//2nd line code
if((PTB & 0x40)==64)//if pin PTB6 PTB then Voltage Dsplay only
{
out(0xC0,0);//Line 2 Character 1 (Position)
if ((PTB & 0x80)==128) out('D',1);//1 (if PTB7 then DC Display
else out('A',1);//1
out('C',1);//2
out(' ',1);//3
out('C',1);//4
out('u',1);//5
out('r',1);//6
out('r',1);//7
out('e',1);//8
out('n',1);//9
out('t',1);//10
out(' ',1);//11
out('0',1);//12
out('0',1);//13
out('.',1);//14
out('0',1);//15
out('A',1);//16
}
}
}
best regards
Pallav