Prop Shield on Maple Mini

Status
Not open for further replies.

Vivat

New member
It seems that the Prop Shield does not work with a Maple Mini.
I connected just 4 wires (+3.3V to +3.3V, GND to GND, SCL to SDL, SDA to SDA) and run a very simple sketch:
#include <Wire.h>

uint8_t addr = 0x60, reg = 0x0C;

void setup()
{
Serial.begin(115200);
Wire.begin();
}

void loop()
{
uint8_t b;
Wire.beginTransmission(addr);
Wire.write((uint8_t) reg);
if((b = Wire.endTransmission()) != 0)
{
Serial.print("endTransmission error = ");
Serial.println(b, HEX);
return;
}
Wire.beginTransmission(addr);
if(!Wire.requestFrom(addr, (uint8_t) 1))
{
Serial.println("requestFrom error");
return;
}
if(Wire.available() != 1)
{
Serial.println("no data available");
return;
}

Serial.print("Who am I = ");
Serial.println(Wire.read(), HEX);
delay(1000);
}

The result is "Who am I = 0". All registers that I try to read result in a zero value. It is the same with all sensors on the Prop Shield (FXOS8700, FXAS21002, MPL3115).
I connected some other sensor boards (L3G4200, BMP180) to the Maple and ran the same sketch (with fitting addresses and registers) and it works. On the other hand I also wired the Prop Shield in the same way to an Arduino Nano and this works as well. Only the combination Maple Mini - Prop Shield does not work. Whereby the hardware connection seems to be OK, otherwise the endTransmission command would return an error. Since this is part of a bigger project, I rely somehow on the Maple and cannot switch easily to a Teensy.
Any suggestions? Thanks in advance.
 
Your sketch also returns 0 on T3.2 hooked to propshield. These sensors, or at least the MPL3115A2 (address 0x60) use I2C repeated start, so to get it to work on T3.2, you have to use endTransmission(false) and not use the 2nd beginTransmission(). Teensy and Arduino Wire lib supports repeated start. I don't know if your Maple Wire lib supports it. The Wire lib for the old Maple IDE does not.
 
Thank you, Manitou. That's it. The Maple does not support repeated start. I checked the code of the library and the parameter of endTransmission is finally not used:

uint8 WireBase::endTransmission(bool stop) {
uint8 retVal;
if (tx_buf_overflow) {
return EDATA;
}
retVal = process(stop);// Changed so that the return value from process is returned by this function see also the return line below
tx_buf_idx = 0;
tx_buf_overflow = false;
return retVal;//SUCCESS;
}
->
uint8 TwoWire::process(uint8 stop) {
int8 res = i2c_master_xfer(sel_hard, &itc_msg, 1, 0);
if (res == I2C_ERROR_PROTOCOL) {
if (sel_hard->error_flags & I2C_SR1_AF) { /* NACK */
res = (sel_hard->error_flags & I2C_SR1_ADDR ? ENACKADDR :
ENACKTRNS);
} else if (sel_hard->error_flags & I2C_SR1_OVR) { /* Over/Underrun */
res = EDATA;
} else { /* Bus or Arbitration error */
res = EOTHER;
}
i2c_disable(sel_hard);
i2c_master_enable(sel_hard, (I2C_BUS_RESET | dev_flags));
}
return res;
}

Any suggestions how to change "process" to support repeated start?
 
Status
Not open for further replies.
Back
Top