Paulchen 999
23.03.2014, 14:47
Hallo
Versuche das Display von Pollin mit dem I2C Adapter in Betrieb zu nehmen. Habe bisher den folgenden Code:
#define F_CPU 16000000UL
#include "i2cmaster.h"
#include <util/delay.h>
#include "lcd.h"
#include "i2clcd.h"
#define LCD_I2C_ADDRESS 0x40 // Adresse I2C
#define ENABLE_MASK 0b01000000
#define DISABLE_MASK 0b10111111
#define COMMAND_MASK 0b00000000
#define DATA_MASK 0b00100000
#define INIT_4BIT_MODE 0b00000010
void write_to_pcf8574(char data)
{
i2c_write(data);
_delay_us(40);
i2c_write(data | ENABLE_MASK);
_delay_us(40);
i2c_write(data & DISABLE_MASK);
_delay_us(40);
}
void write_byte(char data, char mask)
{
//write the high nibble first...
char nibble = mask | ((data & 0xF0) >> 4);
write_to_pcf8574(nibble);
//...then the low nibble
nibble = mask | (data & 0x0F);
write_to_pcf8574(nibble);
}
void write_command(char data)
{
write_byte(data, COMMAND_MASK);
}
void write_data(char data)
{
write_byte(data, DATA_MASK);
}
void write_string(char string)
{
while (string)
{
write_data(string);
string++;
}
}
void init_display()
{
//turn on 4 bit mode
write_to_pcf8574(INIT_4BIT_MODE);
write_command(0x28);
_delay_ms(50);
write_command(0x0c);
_delay_ms(50);
write_command(0x06);
_delay_ms(50);
write_command(0x01);
_delay_ms(50);
write_command(0x0f);
_delay_ms(50);
}
int main()
{
lcd_init();
i2c_init();
i2c_start_wait(LCD_I2C_ADDRESS + I2C_WRITE);
write_string("Hello World");
i2c_stop();
return 0;
}
Arbeite mit einem ATmega 32, 16 MHz, AVR Studio 6, PCF8574 Adresse 0x40. Die Datein habe ich eingebunden
Bekomme die folgenden Fehlermeldungen. Leider konnte ich diese nicht zuordnen:
Warning 2 declared here
Warning 4 expected 'char' but argument is of type 'char *'
Warning 3 passing argument 1 of 'write_string' makes integer from pointer without a cast [enabled by default]
Error 1 too few arguments to function 'lcd_init'
Versuche das Display von Pollin mit dem I2C Adapter in Betrieb zu nehmen. Habe bisher den folgenden Code:
#define F_CPU 16000000UL
#include "i2cmaster.h"
#include <util/delay.h>
#include "lcd.h"
#include "i2clcd.h"
#define LCD_I2C_ADDRESS 0x40 // Adresse I2C
#define ENABLE_MASK 0b01000000
#define DISABLE_MASK 0b10111111
#define COMMAND_MASK 0b00000000
#define DATA_MASK 0b00100000
#define INIT_4BIT_MODE 0b00000010
void write_to_pcf8574(char data)
{
i2c_write(data);
_delay_us(40);
i2c_write(data | ENABLE_MASK);
_delay_us(40);
i2c_write(data & DISABLE_MASK);
_delay_us(40);
}
void write_byte(char data, char mask)
{
//write the high nibble first...
char nibble = mask | ((data & 0xF0) >> 4);
write_to_pcf8574(nibble);
//...then the low nibble
nibble = mask | (data & 0x0F);
write_to_pcf8574(nibble);
}
void write_command(char data)
{
write_byte(data, COMMAND_MASK);
}
void write_data(char data)
{
write_byte(data, DATA_MASK);
}
void write_string(char string)
{
while (string)
{
write_data(string);
string++;
}
}
void init_display()
{
//turn on 4 bit mode
write_to_pcf8574(INIT_4BIT_MODE);
write_command(0x28);
_delay_ms(50);
write_command(0x0c);
_delay_ms(50);
write_command(0x06);
_delay_ms(50);
write_command(0x01);
_delay_ms(50);
write_command(0x0f);
_delay_ms(50);
}
int main()
{
lcd_init();
i2c_init();
i2c_start_wait(LCD_I2C_ADDRESS + I2C_WRITE);
write_string("Hello World");
i2c_stop();
return 0;
}
Arbeite mit einem ATmega 32, 16 MHz, AVR Studio 6, PCF8574 Adresse 0x40. Die Datein habe ich eingebunden
Bekomme die folgenden Fehlermeldungen. Leider konnte ich diese nicht zuordnen:
Warning 2 declared here
Warning 4 expected 'char' but argument is of type 'char *'
Warning 3 passing argument 1 of 'write_string' makes integer from pointer without a cast [enabled by default]
Error 1 too few arguments to function 'lcd_init'