-
Notifications
You must be signed in to change notification settings - Fork 27
ADC hang up in Master Controlled or Fast Mode #25
Comments
Hi, |
@julisNew Unfortunately, as the original post mentions, I've tried a few ways to try and implement a general reset as suggested in section 5.61 of the User Manual, but nothing has worked for me yet. To be specific, here are two ways I've tried:
// Send general reset command to magnetometer. Intended to deal with the known lock-up issue. Doesn't work?
void sendI2CReset() {
delay(1000);
Wire1.beginTransmission(0x00); // 0x00 is the general call address
Wire1.write(0x00); // Sending 0x00
byte error = Wire1.endTransmission();
if (error == 0) {
mag.end();
mag.begin(Wire1);
mag.setAccessMode(mag.MASTERCONTROLLEDMODE);
mag.disableTemp();
delay(50);
Serial.println("General call sent successfully.");
} else {
Serial.print("Error sending general call: ");
Serial.println(error);
}
} In both cases, I get the same result. The only thing that actually "works" is using watchdog_reboot(0,0,0); To reboot the uC, which is problematic and not a realistic solution for my needs. Regarding the suggestion to use the TLV493D-A2BW instead - in future projects, I will. For some added context, I am using these two devices: |
The easiest solution would be if you were able to control the VDD of the sensor with a pin from the uC. Then you could simply reset the sensor by pulling the VDD low, wait a bit, and setting it high again. It's interesting that rebooting the uC works. Because if the VDD of the sensor is not controlled by the microcontroller, then rebooting the uC shouldn't change the hang-up state from the sensor. Except that when you reboot, the
|
@9Volts9er Thanks, That was something I had tried before, without luck. However, I may have found the missing factor. // Todo: removed due to a lot of frame errors
// // if received frame count does not match expected one (frame count from 0 to 3)
// else if( getRegBits(tlv493d::R_FRAMECOUNTER) != (mExpectedFrameCount % 4) )
// {
// ret = TLV493D_FRAME_ERROR;
// } Incomplete code for detecting framecount errors. The key is that the frame counter error can only be detected if the if statement is uncommented. Fortunately, if this if condition is uncommented, then calling end and begin on the Tlv493d object does seem to allow recovery from the ADC hangup. As a result, I think there is a solution that maintains current behaviour while also allowing users of the old sensor to recover from the hangup. E.g., something like: In the sketch:void setup() {
mag.begin(Wire1);
mag.setAccessMode(mag.MASTERCONTROLLEDMODE);
mag.setCheckFrameCountError(true); // Sets flag to true
mag.disableTemp();
calibrateSensor();
} In the lib:Tlv493d.h:class Tlv493d
{
...
public:
...
// read measurement results from sensor
Tlv493d_Error_t updateData(void);
void setCheckFrameCountError(bool state); // Sets flag to state
...
private:
tlv493d::BusInterface_t mInterface;
AccessMode_e mMode;
int16_t mXdata;
int16_t mYdata;
int16_t mZdata;
int16_t mTempdata;
uint8_t mExpectedFrameCount;
bool mCheckFrameCountError; // Bool flag defaults to false Tlv493d.cpp:...
// Todo: removed due to a lot of frame errors
// if received frame count does not match expected one (frame count from 0 to 3)
else if(mCheckFrameCountError && getRegBits(tlv493d::R_FRAMECOUNTER) != (mExpectedFrameCount % 4) )
{
ret = TLV493D_FRAME_ERROR;
}
}
}
}
mExpectedFrameCount = getRegBits(tlv493d::R_FRAMECOUNTER) + 1;
return ret;
}
void Tlv493d::setCheckFrameCountError(bool state)
{
mCheckFrameCountError = state;
}
... Please let me know your thoughts, then I'll make a branch :) |
This issue is stale because it has been open more than 6 weeks with no activity. Please comment on this issue if it's still relevant or it will be closed automatically after 1 week. |
This issue was closed because it has been stalled for 1 week with no activity. |
Hello,
I'm constantly running up against the ADC hangup issue.
I've tried a few ways to try and implement a general reset as suggested in section 5.61 of the User Manual, but nothing has worked for me yet.
Any advice on implementing the general reset?
Additionally,would you consider making it part of the library?
Thanks
The text was updated successfully, but these errors were encountered: