MoinMoin,
ich versuche diesen Abend vergeblich einen DS1307 mit einem Stellaris
Launchpad anzusprechen. Ich möchte dazu gern I2C-Kanal 1(!) benutzen...
Hardwareseitig sind SCL/SDA des DS1307 mit PA6/PA7 des Launchpads
verbunden. Es existieren die entsprechenden zwei 10k-PullUps gegen 3,3V
des Stellaris-Boards...
Das relevante Codefragment sieht ungefähr so aus:
1 | ...
|
2 | #define ADDR_DS1307 0x68
|
3 | ...
|
4 | // I2C(1) initialisieren
|
5 | SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1);
|
6 | SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
|
7 | GPIOPinConfigure(GPIO_PA6_I2C1SCL);
|
8 | GPIOPinConfigure(GPIO_PA7_I2C1SDA);
|
9 | GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7);
|
10 | I2CMasterInitExpClk(I2C1_MASTER_BASE, SysCtlClockGet(), false); // 100kHz
|
11 | ...
|
12 | I2CMasterSlaveAddrSet(I2C1_MASTER_BASE, ADDR_DS1307, false); // write
|
13 | I2CMasterDataPut(I2C1_MASTER_BASE, 0x00); // Sekunden
|
14 | I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_SINGLE_SEND);
|
15 | while(I2CMasterBusBusy(I2C1_MASTER_BASE)){}
|
16 | I2CMasterSlaveAddrSet(I2C1_MASTER_BASE, ADDR_DS1307, true); // read
|
17 | I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
|
18 | while(I2CMasterBusBusy(I2C1_MASTER_BASE)){}
|
19 | ret = I2CMasterDataGet(I2C1_MASTER_BASE);
|
20 | ...
|
...ich bekomme immer 0 in ret zurück!
Es wäre schön, wenn jemand eine Idee hätte!
Grüße & Danke Uwe