Seeed-Studio / Accelerometer_ADXL345

Seeed 3-Axis Digital Accelerometer library
http://www.seeedstudio.com/depot/Grove-3Axis-Digital-Accelerometer16g-p-1156.html
MIT License
25 stars 23 forks source link

Hice una ISR pero... #12

Open facukolo opened 1 year ago

facukolo commented 1 year ago

Hice una ISR para la lectura, así no estará siempre consultando por el bus I2C como está la pila FIFO. El problema es que para que funcione debo desconectar la alimentación y volver a conectar (no basta con presionar reset). ¿Alguna idea de lo que está pasando?

ackPeng commented 1 day ago

I guess there may be several reasons:

  1. I2C bus hang The device on the I2C bus may not release the bus correctly in some cases, such as reading is not completed during interruption, causing the SDA or SCL line to remain at a low level. This will cause the I2C bus to lock up and the host (your microcontroller) cannot reinitialize communication until the system is powered off and restarted. Pressing the reset button may not reset the peripheral or release the bus. Solution: You can try to ensure that the I2C bus is properly released every time a read is completed in the ISR, or reset the I2C peripheral when a bus error is detected. Some microcontrollers also provide the function of soft restarting the I2C peripheral, which can be triggered when a problem is detected.
  2. Interrupt priority or interrupt nesting problem If your ISR does not handle an event correctly, it may cause interrupt priority conflicts or too many nested interrupts, causing the system to lock up. Solution: Make sure the logic in the ISR is simple and fast, avoid occupying interrupts for a long time, especially the clock signal required for I2C communication should be performed in the interrupt context as much as possible.