Das ist nicht sehr üblich.
Die hex Aderesen brauchst du zumeist nicht ändern.
Code:
#ifndef F_CPU
#define F_CPU 16000000 /**< Change this to the clock-rate of your microcontroller */
#endif
#define wait1us _delay_loop_1((F_CPU * 0.000001) / 3) /**< 1 us delay */
#define wait1ms _delay_loop_2((F_CPU * 0.001) / 4) /**< 1 ms delay */
/*@}*/
//-------------------------------------------------------------------------------------------------------------------
#include <util/delay.h>
#include <stdbool.h>
#include <stdint.h>
#include "i2cmaster.h"
//--Display-Configuration-Settings-----------------------------------------------------------------------------------
/** \defgroup DISPLAY_CONFIGURATION DISPLAY CONFIGURATION
Change this settings to your configuration.
*/
/*@{*/
#define LCD_I2C_DEVICE 0x40 /**< Change this to the address of your expander */
#define LCD_LINES 4 /**< Enter the number of lines of your display here */
#define LCD_ROWS 20 /**< Enter the number of rows of your display here */
#define LCD_LINE1 0x00 /**< This should be 0x00 on all displays */
#define LCD_LINE2 0x20 /**< Change this to the address for line 2 on your display */
#define LCD_LINE3 0x40 /**< Change this to the address for line 3 on your display */
#define LCD_LINE4 0x60 /**< Change this to the address for line 4 on your display */
/*@}*/
//-------------------------------------------------------------------------------------------------------------------
//--The-following-definitions-are-corresponding-to-the-PIN-Assignment-(see-above)------------------------------------
/** \defgroup PIN_ASSIGNMENT PIN ASSIGNMENT
This pin assignment shows how the display is connected to the PCF8574.
*/
/*@{*/
#define LCD_D4_PIN 3 /**< LCD-Pin DB4 is connected to P3 on the PCF8574 */
#define LCD_D5_PIN 2 /**< LCD-Pin DB5 is connected to P2 on the PCF8574 */
#define LCD_D6_PIN 1 /**< LCD-Pin DB6 is connected to P1 on the PCF8574 */
#define LCD_D7_PIN 0 /**< LCD-Pin DB7 is connected to P0 on the PCF8574 */
#define LCD_RS_PIN 7 /**< LCD-Pin RS is connected to P7 on the PCF8574 */
#define LCD_RW_PIN 6 /**< LCD-Pin RW is connected to P6 on the PCF8574 */
#define LCD_EMPTY_PIN 4 /**< this pin is not connected */
#define LCD_E_PIN 5 /**< LCD-Pin E is connected to P5 on the PCF8574 */
/*@}*/
Am Anfang die F_CPU einstellen
Unter Display-Configuration-Settings
Die I2C-Adresse des Port-Expander
Anzahl der Zeilen
Anzahl der Zeichen je Zeile
Unter Pin-Assignment
Hier musst du die Zuordnung der Expander-Pin zu den LCD-PIn machen
Sonst sollte für Standardfunktionen keine weitere Einstellung notwendig sein.
Bist du sicher das I2C überhaupt funktioniert
Lesezeichen