| ??? 02/17/10 07:20 Read: times |
#173210 - Hopefull the code will appear in the right place now. Responding to: ???'s previous message |
DearAndy,
Hope this attempt at pasting the code is fine. This program is essentially the same though still there is only partial success. 1. I'm using a standard kit from a vendor that has been used in the past 2. if I change the "sec_cnt" variable to data type "unsigned int" or "unsigned long int" then the program does not process & the built in simulator does not proces "sec_cnt" at all. Thank you. ...insert code here[/#include <Intel8052.h>
#include <standard.h>
BIT RS P0.0;
BIT RW P0.1;
BIT E P0.2;
BIT LED P2.0;
BIT LED2 P2.1;
// data pins to LCD P0.4 to P0.7//
unsigned char p0data;
unsigned char temp;
unsigned char ch;
unsigned char sec_cnt;
char message[33] = "Vaishakh Chavan is here " ;
interrupt (INT_TMR0) timer0isr () using 1
{
// INT_TMR0 is a #defined constant
// it is defined in STANDARD.H which is #included in this program
// This ISR uses register bank 1
TH0 = 0xd8 ; /*Reload timer */
TL0 = 0xf0 ;
sec_cnt -- ;
if (!sec_cnt)
{
sec_cnt = 1000;
LED = ~LED ;
LED2=~LED;
}
}
void lcd_enable()
{
E=1;
//delay(500);
E=0;
delay(500);
}
void lcd_writecom(unsigned char ch)// writing commands to LCD //
{
unsigned char temp;
temp=ch;
temp= temp & 0xf0;
temp=temp|0x08; // holding P0.3 high //
P0=temp;
lcd_enable();
temp= ( ch << 4s);
// move Lower nibble to higger nibbble //
temp= temp & 0xf0;
temp|=0x08; // holding P0.3 high //
P0=temp;
lcd_enable();
}
void lcd_writetxt(unsigned char ch) // writing data to LCD //
{
unsigned char temp;
temp=ch;
temp= temp & 0xf0;
temp=temp|0x09; // holding P0.3 high & RS set to data mode //
P0=temp;
lcd_enable();
temp= ( ch << 4s);
// move Lower nibble to higger nibbble //
temp= temp & 0xf0;
temp=temp|0x09;
P0=temp;
lcd_enable();
}
void display_lcd (char arr[])
{
// displays first 16 characters in the string on line 1 and
// remaining 16 characters on 2nd line
// assumed 16 X 2 display
unsigned char count ;
lcd_writecom(0x80) ; // first line
for(count=0;count<16;count++)
{
if(arr[count])
lcd_writetxt(arr[count]) ;
else
return ; // if string is < 32 chars, return
}
lcd_writecom(0xc0) ; // second line
for(count=16;count<32;count++)
{
if (arr[count])
lcd_writetxt(arr[count]);
else
return ; // if string is < 32 chars, return
}
}
void main ()
{
// LCD initialization //
P0=0xff;
delay_ms(250);
p0data=0x08; // unused pin pulled high
P0=p0data;
delay(5000); //lcd_init();// initialize the display
lcd_writecom(0x01);
delay(5000);
lcd_writecom(0x28);
delay(5000);
lcd_writecom(0x08);
delay(5000);
lcd_writecom(0x0C);
delay(5000);
lcd_writecom(0x06);
delay(5000);
TMOD = 0x01 ;
TCON = 0x10 ;
TH0 = 0xd8 ; // Initial value
TL0 = 0xf0 ; // such that Timer0 will overflow every 10 ms
lcd_writecom(0x01);
IE = 0x82 ; // enable timer0 interrupt
while(1)
{
display_lcd(message); // display the message
lcd_writecom(0xc8);
lcd_writetxt('X');
}
}
]
|
| Topic | Author | Date |
| Help with LCD code ( something vague happening here ) | 01/01/70 00:00 | |
| Better attention to detail? | 01/01/70 00:00 | |
| The LCD works but... | 01/01/70 00:00 | |
| Reset; Timing | 01/01/70 00:00 | |
| Yes I did | 01/01/70 00:00 | |
| No, that doesn't follow | 01/01/70 00:00 | |
Flashing LED | 01/01/70 00:00 | |
| Hopefull the code will appear in the right place now. | 01/01/70 00:00 | |
| built in simulator does not proces "sec_cnt" at all. | 01/01/70 00:00 | |
| Simulator | 01/01/70 00:00 | |
| What tools? | 01/01/70 00:00 | |
| does the LED blink? | 01/01/70 00:00 | |
| Thank you | 01/01/70 00:00 |



