Hallo.
Ich verwende im Moment das Stellaris Launchpad mit dem LM4F120H5QR.
Gehört zur CLASS_IS_BLIZZARD. Weiters verwende ich die dazugehörige
driverlib. Einige Sachen funktionierten gleich auf Anhieb mit den APIs
aber dann wollte ich I2C verwenden und 30h später ist noch nicht einmal
der DrecksSCL-Pin richtige eingestellt...
Deshalb wollte ich fragen ob jemand damit Erfahrung hat oder ähnliche
Probleme mit I2C hatte.
Was mir zB auffiel war, dass in der Definition vom I2CSCL-pin nicht
opendrain mit pull-up verwendet wird sondern standard push-pull. Ich
habe das geändert aber der Pin bleibt dauerend LOW. Beim anderen (SDA)
passt die Einstellung schon immer. Ich müsste mir jetzt anscheinend
alles von der SysControl bis GpioConfigs und I2C nochmal durchschauen ob
da noch wo was nicht passt, weil ich hab echt keinen Plan mehr...
Zum Einstellen des I2C verwende ich folgendes:
1 | GPIOPinConfigure(0x00010803);// GPIO_PB2_I2C0SCL
|
2 | GPIOPinConfigure(0x00010C03);// GPIO_PB3_I2C0SDA
|
3 | GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
|
4 | myGPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
|
5 | Uart_Send(UART0_BASE,"I2C GPIO DONE\n\r\0",0);
|
6 | I2CMasterInitExpClk(I2C0_MASTER_BASE,SysCtlClockGet(),false);
|
7 | I2CMasterEnable(I2C0_MASTER_BASE);
|
Die Funktion myGPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2); ist im
Grunde wie GPIOPinTypeI2CSCL, nur dass statt
1 | void
|
2 | GPIOPinTypeI2CSCL(unsigned long ulPort, unsigned char ucPins)
|
3 | {
|
4 | //
|
5 | // Check the arguments.
|
6 | //
|
7 | ASSERT(GPIOBaseValid(ulPort));
|
8 |
|
9 | //
|
10 | // Make the pin(s) be peripheral controlled.
|
11 | //
|
12 | GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_HW);
|
13 |
|
14 | //
|
15 | // Set the pad(s) for open-drain operation with a weak pull-up.
|
16 | //
|
17 | if(CLASS_IS_SANDSTORM || CLASS_IS_FURY || CLASS_IS_DUSTDEVIL ||
|
18 | CLASS_IS_TEMPEST || CLASS_IS_FIRESTORM)
|
19 | {
|
20 | GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_OD); //open drain
|
21 | }
|
22 | else // jo, den hab ich ... BLIZZARD
|
23 | {
|
24 | GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD); // pushpull
|
25 | }
|
26 | }
|
das so geändert wurde wie normalerweise I2C geht :
1 | void
|
2 | myGPIOPinTypeI2CSCL(unsigned long ulPort, unsigned char ucPins)
|
3 | {
|
4 | //
|
5 | // Check the arguments. GPIO_PIN_TYPE_OD_WPU
|
6 | //
|
7 | ASSERT(GPIOBaseValid(ulPort));
|
8 |
|
9 | //
|
10 | // Make the pin(s) be peripheral controlled.
|
11 | //
|
12 | GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_HW);
|
13 |
|
14 | //
|
15 | // Set the pad(s) for open-drain operation with a weak pull-up.
|
16 | //
|
17 | GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_OD_WPU); // open drain weak internal pull up
|
18 |
|
19 | }
|
Über jede Hilfe/ Aufmunterung glücklich!
Matthias