Hallo,
ich versuche ein Batron i2c Display mit einem Atmega8 anzusteuern.
Hardware:
- Batron BT HQ 21605AV-YETF-LED04-I2C-5V
( Philips PCF2119 Controller )
- SDA und SCL mit 4,7 K auf VDD
- Atmega8 (mit internem OC auf STK500)
Software:
- GCC-AVR 4.2.2
- Peter Fleury`s I2C Master Interface
Meine SRC-Änderungen:
- test_i2cmaster.c angepasst (siehe *.zip)
- i2cmaster.s die SDA und SCL Pinne eingestellt
- makefile für Atmega8 konfiguriert
Ich habe mir die "test_i2cmaster.c" genommen und nach meinen
Bedürfnissen geändern. Leider sieht man auf dem LCD gar nichts.
Hier meine "test_i2cmaster.c". Die kompletten Files + Datenblätter
liegen im rar file.
1 | #include <avr/io.h>
|
2 | #define F_CPU 1000000UL // 1 MHz
|
3 | #include <util/delay.h>
|
4 | #include "i2cmaster.h"
|
5 |
|
6 | #define lcd_address 0x74 // device address
|
7 |
|
8 |
|
9 | unsigned char ret;
|
10 |
|
11 | void blink(void)
|
12 | {
|
13 | PORTB = 0xFF;
|
14 | _delay_ms(500);
|
15 | PORTB = 0x00;
|
16 | _delay_ms(500);
|
17 | PORTB = 0xFF;
|
18 | _delay_ms(500);
|
19 | PORTB = 0x00;
|
20 | }
|
21 |
|
22 | void lcd_init(void)
|
23 | {
|
24 |
|
25 | ret = i2c_start(lcd_address+I2C_WRITE); // set device address and write mode
|
26 | if ( ret )
|
27 | {
|
28 | /* failed to issue start condition, possibly no device found */
|
29 | i2c_stop();
|
30 | PORTB=0xFF; // activate all 8 LED to show error */
|
31 | }
|
32 | else
|
33 | {
|
34 | i2c_write(0x80); // Control byte for Instruction
|
35 | i2c_write(0x30);
|
36 | i2c_write(0x0E); // DDRAM Address set to 00hex
|
37 | i2c_write(0x06); // return home
|
38 | }
|
39 | }
|
40 |
|
41 | void write_char(void)
|
42 | {
|
43 |
|
44 | ret = i2c_start(lcd_address+I2C_WRITE); // set device address and write mode
|
45 | if ( ret )
|
46 | {
|
47 | /* failed to issue start condition, possibly no device found */
|
48 | i2c_stop();
|
49 | PORTB=0xFF; // activate all 8 LED to show error */
|
50 | }
|
51 | else
|
52 | {
|
53 | i2c_write(0x40); // Control byte for Data
|
54 |
|
55 | int i;
|
56 | for (i=1;i<=16;i++)
|
57 | {
|
58 | i2c_write(0xC0+i); // Write ABCDE....
|
59 | }
|
60 | i2c_stop();
|
61 | }
|
62 | }
|
63 |
|
64 |
|
65 |
|
66 | int main(void)
|
67 | {
|
68 | DDRB = 0x00;
|
69 |
|
70 | i2c_init();
|
71 |
|
72 | lcd_init();
|
73 |
|
74 | write_char();
|
75 | }
|
Ich bin für jeden Tip bzw. Code dankbar.
Gruss mrtom