Kein Erfolg, den MPU6050 aus dem SLEEP-Modus zu bringen. Ich verstehe, dass das SLEEP-Bit (Bit 6) gelöscht werden muss, aber das Lesen des Power-Management-Registers nach dem Ausführen des Löschvorgangs gibt 0x40 zurück. d. h. Bit 6 wurde nicht gelöscht.MPU6050 Power Management mit Tiva C Direct-Register-Modus
Ja, das ist für eine Aufgabe, und als solche dürfen wir keine Bibliotheken usw. verwenden. Mein Tutor konnte nicht helfen und schlug vor, dass ich hier frage.
Mein I2C-Setup ist wie folgt
void I2C1_Setup(void)
{
//Setup I2C 1 on PORT A Pins 6, 7
// GPIO A
SYSCTL_RCGCGPIO |= (1<<0); while ((SYSCTL_PRGPIO & (1<<0)) != (1<<0)) {}
GPIOA_AFSEL |= (1<<6)|(1<<7);
GPIOA_PCTL &= ~(0xFF<<24);
GPIOA_PCTL |= (3<<28)|(3<<24);
GPIOA_DEN |= (1<<6)|(1<<7);
GPIOA_ODR |= (1<<7);
// I2C 1
SYSCTL_RCGCI2C |= (1<<1); while ((SYSCTL_PRI2C & (1<<1)) != (1<<1)) {}
/*
TPR = (System Clock/(2*(SCL_LP + SCL_HP)*SCL_CLK))-1;
TPR = (16MHz/(2*(6+4)*100000))-1;
TPR = 7
*/
I2C1_MCR = (1<<4); //master mode
I2C1_MTPR = (7<<0); //100Kbps
//Disable SLEEP mode
I2C1_MSA = 0xD0; // Set slave address and write mode
I2C1_MDR = 0x6B; // Power management register
I2C1_MCS = 0x3; // start run mode
while (!((I2C1_MCS & 1) != 0)) {}
while ((I2C1_MCS & 1) == 0) {} // poll busy
I2C1_MDR = 0;
I2C1_MCS = 0x7; // stop start run mode
while (!((I2C1_MCS & 1) != 0)) {}
while ((I2C1_MCS & 1) == 0) {} // poll busy
}
Um den Wert des Power-Management-Register zu testen
I2C1_MSA = 0xD0; // transmit mode
I2C1_MDR = 0x6B; // register address
I2C1_MCS = 3; // start run mode
while (!((I2C1_MCS & 1) != 0)) {}
while ((I2C1_MCS & 1) != 0) {} // poll busy
I2C1_MSA = 0xD1; // receive mode
I2C1_MCS = 7; // stop start run mode
while (!((I2C1_MCS & 1) != 0)) {}
while ((I2C1_MCS & 1) != 0) {} // poll busy
int data;
data = I2C1_MDR;
Der Rückgabewert verwenden für diese 0x40 ist. Wenn ich dieselben Schritte durchführe, um das WHO_AM_I-Register (0x75) zu überprüfen, wird bestätigt, dass die Slave-Adresse 0x68 ist.
weiß, dass ich die MPU funktioniert im Allgemeinen wie wir in der Lage waren Lesungen auf einem Arduino bekommt die einfache Skizze hier zur Verfügung gestellt mit (https://playground.arduino.cc/Main/MPU-6050)
Ich bin mit dem TM4C123GH6PM und keil uvision5.
Wirklich nicht sicher, was hier falsch läuft.
Jede Hilfe wird geschätzt.