Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: ad5933.cpp
- Revision:
- 4:1ecb56465953
- Parent:
- 3:b844dd14179c
- Child:
- 5:2dc8c3f02788
--- a/ad5933.cpp Mon May 11 13:48:59 2015 +0000
+++ b/ad5933.cpp Wed May 13 07:52:49 2015 +0000
@@ -53,7 +53,11 @@
bool AD5933::setRegister(uint8_t RegisterAdress, uint8_t RegisterValue)
{
sCom.start();
- bool output = (sCom.write(WRITE_CMD) + sCom.write(RegisterAdress) + sCom.write(RegisterValue)) == 3;
+ bool output = sCom.write(WRITE_CMD);
+ wait_ms(1);
+ sCom.write(RegisterAdress);
+ wait_ms(1);
+ sCom.write(RegisterValue);
sCom.stop();
return output;
}
@@ -98,7 +102,7 @@
bool AD5933::setControlReg(uint8_t Command)
{
return setRegister(0x80, PGAandVoltout | Command);
-
+ //return setRegister(0x80, Command);
}
bool AD5933::setFrequencySweepParam(unsigned int startFreq, unsigned int stepFreq, unsigned int nrOfSteps)
@@ -168,16 +172,24 @@
return setRegister(0x81, data);
}
+bool AD5933::standby()
+{
+ return setControlReg(STANDBY);
+
+}
+
bool AD5933::Measure(bool increment)
{
if(firstMeasurement) {
- reset();
-
+ //reset();
+ setControlReg(STANDBY);
+ wait_ms(10);
setControlReg(INIT_FREQ);
wait_ms(250);
setControlReg(INIT_SWEEP);
wait_ms(5);
+ firstMeasurement = false;
return getData();
} else if(increment) {
setControlReg(INCR_FREQ);
@@ -185,7 +197,7 @@
return getData();
} else {
setControlReg(REPE_FREQ);
- wait_ms(5);
+ wait_ms(500);
return getData();
}
}
@@ -201,9 +213,10 @@
i++;
}
if(i == 10)
- return false;
+ output = false;
+ //return false;
- output = gotoAdressPointer(0x82);
+ output &= gotoAdressPointer(0x82);
output &= readBlock(data, 4);
real = data[0] << 8 | data[1];
imaginary = data[2] << 8 | data[3];
@@ -214,13 +227,17 @@
{
int i = 0;
uint8_t data[2];
+
+ setControlReg(MEAS_TEMP);
+ wait_ms(5);
while((getRegister(0x8F) != 0x01) && i < 10) {
- wait_ms(5);
+ wait_ms(100);
i++;
}
- if(i == 10)
- return false;
+ //if(i == 10)
+
+ //return 100;
gotoAdressPointer(0x92);
readBlock(data, 2);