GrumpyOldPizza / arduino-STM32L4

69 stars 60 forks source link

Problems with i2c #18

Open laterrps opened 7 years ago

laterrps commented 7 years ago

I have problem using i2c comunication i am using mpu6050 i dont know why but the program is freezing and interrupts still working

laterrps commented 7 years ago

this was happening with max30102 sensor too this has been happening at randomly way.

kriswiner commented 7 years ago

Do you have 4K7 pullups on I2C?

On Wed, Aug 23, 2017 at 2:03 PM, laterrps notifications@github.com wrote:

this was happening with max30102 sensor too this has been happening at randomly way.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/arduino-STM32L4/issues/18#issuecomment-324461848, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qkCELzmy6ZweslE1by4fh9L-irnCks5sbJOngaJpZM4PAlLn .

laterrps commented 7 years ago

image

i am using 2.2k resistors

kriswiner commented 7 years ago

What does an I2C scan show? Can you discover the MPU6050 on the I2C bus.

I have successfully received data from dozens of MPU9250 using the STM32L4 so the problem is likely connection or software.

How are you initializing the wire library?

On Wed, Aug 23, 2017 at 2:30 PM, laterrps notifications@github.com wrote:

[image: image] https://user-images.githubusercontent.com/26884777/29639440-a028ae4e-880f-11e7-8bd7-f8282af6a8bc.png

i am using 2.2k resistors

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/arduino-STM32L4/issues/18#issuecomment-324468296, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qj6rMoqohQlb7FR6DkQCLNuSHUv_ks5sbJoMgaJpZM4PAlLn .

laterrps commented 7 years ago

I initialize like this: Wire.setClock(reloj); Wire.begin();

void movimiento() { static bool calculaFC;

if (movread == true) {
    //Serial.println("acc1");
    flagMovimiento=Acel.getIntMotionStatus();
    movimientoActualizado = false;
    movread == false;
    if (flagMovimiento == true && movimientoActualizado == false) {
        /*Serial.println("update1");*/
        tiempoUltimoMovimiento = millis();
        movimientoActualizado = true;
        /*Serial.println("update2");*/

    }
    armv7m_timer_create(&timerMuestreoMovimiento, (armv7m_timer_callback_t)muestraMovimiento);

    armv7m_timer_start(&timerMuestreoMovimiento,200);
    //armv7m_timer_start(&timerMuestreoMovimiento, 100);
    movread = false;
    //Serial.println(flagMovimiento);
}
int tiempoActual = millis();
if (((tiempoActual - tiempoUltimoMovimiento) > 5000) && calculaFC==false) {
    calculaFC = true;
    correct = 0;
    configurarAfe4400();
    //Serial.println("timer");
    armv7m_timer_create(&timerPersistenciaFrecuenciaCardiaca, (armv7m_timer_callback_t)cancelarLecturaFrecuenciaCardiaca);

    armv7m_timer_start(&timerPersistenciaFrecuenciaCardiaca, 40000);
    stopedByTimer = false;
}
if (calculaFC) {
    tiempoUltimoMovimiento = millis();
    //Serial.println("dsp");
    DSP(false);
    if (correct == 6) {
        char ppm[10];
        calculaFC = false;
        float fc = auxFrec / 5;
        powerDownAfe4400();
        correct = 0;
        Oled.setDrawColor(0);
        Oled.drawBox(0, 16, 131, 16);
        Oled.setDrawColor(1);
        Oled.drawStr(0,16,"PPM");
        sprintf(ppm, "%.0f", fc);
        Oled.drawStr(50, 16, ppm);

    }
    else {
        if (stopedByTimer == true) {
            Serial.println("Error en lectura");
            ///////////////AQUI PUEDE IR SINTETIZADOR DE VOZ//////////////////
            ////////////////O REINTENTAR CALCULO DE FRECUENCIA CARDIACA///////////
            calculaFC = false;
            powerDownAfe4400();
            Oled.setDrawColor(0);
            Oled.drawBox(0, 16, 131, 16);
            Oled.setDrawColor(1);
            Oled.drawStr(0, 16, "Err.");
            Oled.sendBuffer();

            correct = 0;
            stopedByTimer = false;
        }

    }

}

}

laterrps commented 7 years ago

I am using mpu library (Jeff Rowberg)

kriswiner commented 7 years ago

"I am using mpu library (Jeff Rowberg)"

Yup, that's the problem...

On Wed, Aug 23, 2017 at 2:42 PM, laterrps notifications@github.com wrote:

I am using mpu library (Jeff Rowberg)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/arduino-STM32L4/issues/18#issuecomment-324470960, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qkjEESlj7OLxoZp4F1WsaPfmM0WTks5sbJzagaJpZM4PAlLn .

laterrps commented 7 years ago

JAJAJAJ Ok ok!

you recomendme make my own algorithm? or does exist some other library?

laterrps commented 7 years ago

or do you have any example?

kriswiner commented 7 years ago

I havent used the MPU6050 for years having graduated to the MPU9250 but here is what used to work for me. You will have to modify the wire calls or maybe not. But there are bound to be some changes required to sun on the STM32L4.

https://github.com/kriswiner/MPU6050

On Wed, Aug 23, 2017 at 2:52 PM, laterrps notifications@github.com wrote:

or do you have any example?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/arduino-STM32L4/issues/18#issuecomment-324473104, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qqkbZqm_6UGELvRhFoFNoMzIvhIuks5sbJ8cgaJpZM4PAlLn .

laterrps commented 7 years ago

I implemented a motion detect algorithm and it looks like it's working correctly thank you for your help i'll be carefull and instead of copy work from internet i will implement my own code.

kriswiner commented 7 years ago

Good for you!

On Wed, Aug 23, 2017 at 5:39 PM, laterrps notifications@github.com wrote:

I implemented a motion detect algorithm and it looks like it's working correctly thank you for your help i'll be carefull and instead of copy work from internet i will implement my own code.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/arduino-STM32L4/issues/18#issuecomment-324500060, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qpdCq4hbClRUw55CHp5xqB5zZpCiks5sbMYogaJpZM4PAlLn .

laterrps commented 6 years ago

I'm still having problems i did implement this:

Serial.print("status ");Serial.print(Wire.status());Serial.println();
        Serial.print("vector interrupciones  ");Serial.print(interrupcones,BIN);Serial.println();

and this shows in terminal. image and communication get down! but program still running