Hallo,
kann mir jmd helfen bei meinem STM32F103 Prozessor? Im Moment versuche
ich über I2C eine Kommunikation aufzubauen; bis jetzt wird aber nichts
gesendet!"
1 | //i2c clock
|
2 | RCC->APB1ENR |= 0x00400000;
|
3 |
|
4 | //portb clock enable
|
5 | RCC->APB2ENR |= 0x00000008;
|
6 |
|
7 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
|
8 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
9 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
|
10 | GPIO_Init(GPIOB, &GPIO_InitStructure);
|
11 |
|
12 | I2C_InitSt.I2C_Mode = I2C_Mode_I2C;
|
13 | I2C_InitSt.I2C_DutyCycle = I2C_DutyCycle_2;
|
14 | I2C_InitSt.I2C_OwnAddress1 = 0x58; //addr vom eeprom
|
15 | I2C_InitSt.I2C_Ack = I2C_Ack_Enable;
|
16 | I2C_InitSt.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
|
17 | I2C_InitSt.I2C_ClockSpeed = 100000;
|
18 | I2C_Init(I2C2, &I2C_InitSt);
|
19 |
|
20 | /* Enable the selected I2C peripheral I2C_Cmd(I2C2, ENABLE) */
|
21 | I2C2->CR1 |= 0x0001;
|
Nach dieser Initialisierung ist die Clock low und der SDA ist high.
1 | //send start condition
|
2 | I2C2->CR1 |= 0x0100;
|
3 | while (!(I2C_sr() & 0x0001));
|
Das Bit wird richtig gesetzt im SR Register; I2C_sr() gibt den Inhalt
vom Status Register zurück.
1 | I2C2->DR = IntAddr | 0; //addr die beschrieben werden soll
|
2 | while (!(I2C_sr() & 0x0002));
|
Hier wird das entsprechende Bit nicht gesetzt, so dass der Prozessor
hier verweilt; aut dem Bus kann man wie gesagt mit dem Oszi nichts
erkennen; Pullups sind vorhanden.
Gruß
Bernd