bianchi77
Advanced Member level 4
- Joined
- Jun 11, 2009
- Messages
- 1,313
- Helped
- 21
- Reputation
- 44
- Reaction score
- 20
- Trophy points
- 1,318
- Location
- California
- Activity points
- 9,442
I tested on ATMEGA 128
it's ok without passing parameter :
- - - Updated - - -
I tested on ATMEGA 128
it's ok without passing parameter :
- - - Updated - - -
This code can init LCD but can not display character yet, any ideas why ?
it's ok without passing parameter :
Code:
int main(){
DDR_D.b0 = 1;
DDR_D.b1 = 1;
DDR_D.b2 = 1;
DDRA = 0xFF;
while(1){
lcd_data_pin = 0x30;
_delay_ms(1000);
en = 1;
_delay_ms(500);
en = 0;
_delay_ms(500);
lcd_data_pin = 0x38;
_delay_ms(1000);
en = 1;
_delay_ms(500);
en = 0;
}
- - - Updated - - -
I tested on ATMEGA 128
it's ok without passing parameter :
Code:
int main(){
DDR_D.b0 = 1;
DDR_D.b1 = 1;
DDR_D.b2 = 1;
DDRA = 0xFF;
while(1){
lcd_data_pin = 0x30;
_delay_ms(1000);
en = 1;
_delay_ms(500);
en = 0;
_delay_ms(500);
lcd_data_pin = 0x38;
_delay_ms(1000);
en = 1;
_delay_ms(500);
en = 0;
}
- - - Updated - - -
This code can init LCD but can not display character yet, any ideas why ?
Code:
#include <avr/io.h>
#include <util/delay.h>
// structure to allow bit field operations, name conversions: PORTA.0 -> PORT_A.b0 PORTB.7 -> PORT_B.b7
typedef struct{ uint8_t b0:1;
uint8_t b1:1;
uint8_t b2:1;
uint8_t b3:1;
uint8_t b4:1;
uint8_t b5:1;
uint8_t b6:1;
uint8_t b7:1; } bits;
// define all the ports of your microcontroller, add more ports depending on the available mcu ports
#define PORT_D (* (volatile bits *) &PORTD)
#define PIN_D (* (volatile bits *) &PIND)
#define DDR_D (* (volatile bits *) &DDRD)
#define PORT_G (* (volatile bits *) &PORTG)
#define PIN_G (* (volatile bits *) &PING)
#define DDR_G (* (volatile bits *) &DDRG)
//Mention Clock frequency here
#define _XTAL_FREQ 8000000
#define lcd_data_pin PORTA
#define en PORT_D.b0
#define rs PORT_D.b1
#define rw PORT_D.b2
lcd_init()
{
lcd_data_pin = 0x30;
en = 1;
rs = 0;
rw = 0;
_delay_ms(10);
en = 0;
//next command
_delay_ms(100);
lcd_data_pin = 0x38;
en = 1;
rs = 0;
rw = 0;
_delay_ms(10);
en = 0;
_delay_ms(100);
lcd_data_pin = 0x0F;
en = 1;
rs = 0;
rw = 0;
_delay_ms(10);
en = 0;
//next command
_delay_ms(100);
lcd_data_pin = 0x80;
en = 1;
rs = 0;
rw = 0;
_delay_ms(10);
en = 0;
}
void lcd_data()
{
lcd_data_pin = 0x41;// & 0x0F;
en=1;
rs=1;
rw=0;
_delay_ms(10);
en=0;
}
int main(){
DDR_D.b0 = 1;
DDR_D.b1 = 1;
DDR_D.b2 = 1;
DDRA = 0xFF;
lcd_init();
while(1){
lcd_data();
}
return (0);
}