AvansETI / SmartSensor

SmartSensor: a sensor to be used as sensor and actuator within existing buildings.
GNU General Public License v3.0
1 stars 2 forks source link

i2c not working properly #3

Closed macsnoeren closed 3 years ago

macsnoeren commented 3 years ago

At this moment it is not possible to read and write to the various ICs.

macsnoeren commented 3 years ago

Today, the board have been checked and it has been found that the light sensor has been place reversed. This IC has been removed for the moment. All other connections have been checked and it seems to be correctly connected.

macsnoeren commented 3 years ago

The signals of the i2c bus have been checked using an oscilloscope. The signals are okay. When the CO2 sensor is selected, weird things happen. After the data, the SDA bus is pulled low by the device.I think, while we perform a read, the IC waits on a clock to give the data back the processor using SDA.

TODO: Try to read the following bytes and check if the sensor pushes data back!

macsnoeren commented 3 years ago

TODO: The nWake pin of the CO2 sensor is not yet used. This pin needs to be driven low before the i2c bus is used. All GPIO pins of the Atmel are set to input without pullup when started up. Try to set the pinmode to output and drive it low at start up.

macsnoeren commented 3 years ago

From the datasheet is has been found that the IC SHTC3 has a device address 0x70: 111 0000. So, when reading it will be 1110 0000 => E0. And writhing 1110 0001 => E1. Therefore, the address has been changed to E0 in the board support. Please use the address E0.

macsnoeren commented 3 years ago

TODO: Please use 100kHz clock for the "normal mode" i2c operation.

macsnoeren commented 3 years ago

FloBo, are you able to put some info in this issue page, while everything is working now. Except the CO2 sensor.

macsnoeren commented 3 years ago

Found this at: https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-slave-pulling-I2C-clock-data-lines-low-when-not-sending/m-p/628852

Sorry, it is the definition of I2C that slaves must 'pull' the clock-line low to 'pace' a master when return-data is not immediately available. And in ALL cases of microcontroller I2C slave implementations, they ALWAYS pull the clock-line low at every access as uC firmware must supply the return data 'after some time'. Once you have initialized the K22F into I2C 'slave' mode, you are going to have to be sure that it is ALWAYS 'ready' to return data for I2C transactions addressed to it, else it will indeed permanently stall the whole I2C bus. If you don't want the K22F reacting to such transactions, you have to disable this slave mode (for at least those time periods). Does your K22F respond to addressed transactions 'fully normally' when properly enabled?

Maybe, the CO2 sensor is busy initializing. We need to investigate this a bit more.

macsnoeren commented 3 years ago

Some documentation: https://www.ti.com/lit/an/scaa106/scaa106.pdf?ts=1616331517789&ref_url=https%253A%252F%252Fwww.google.com%252F

macsnoeren commented 3 years ago

Both I2C-busses are working properly. CO2 sensor is not working still. New issue will be created for this one.