ADS1246/7/8 24bit ADC converter for Temperature Sensors class
Revision 1:d62be7487e9d, committed 2016-01-19
- Comitter:
- mederic
- Date:
- Tue Jan 19 07:52:07 2016 +0000
- Parent:
- 0:e015f99b8dfb
- Commit message:
- Increase hold time before & after release the CS pin
Changed in this revision
ADS1248.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r e015f99b8dfb -r d62be7487e9d ADS1248.cpp --- a/ADS1248.cpp Wed Sep 17 08:20:38 2014 +0000 +++ b/ADS1248.cpp Tue Jan 19 07:52:07 2016 +0000 @@ -1,5 +1,7 @@ #include "ADS1248.h" +#define ADS1248_HOLD_TIME_US 2 + //***********************************/************************************ // Constructors // //***********************************/************************************ @@ -28,8 +30,9 @@ _start = 1; _cs = 0; _spi.write(en<<1); - wait_us(1); + wait_us(ADS1248_HOLD_TIME_US); _cs = 1; + wait_us(ADS1248_HOLD_TIME_US); waitReady(); } @@ -38,16 +41,18 @@ _cs = 0; _spi.write(SYNC); _spi.write(SYNC); - wait_us(1); - _cs = 1; + wait_us(ADS1248_HOLD_TIME_US); + _cs = 1; + wait_us(ADS1248_HOLD_TIME_US); } void ADS1248::reset(void){ _start = 1; _cs = 0; _spi.write(RESET); - wait_us(1); - _cs = 1; + wait_us(ADS1248_HOLD_TIME_US); + _cs = 1; + wait_us(ADS1248_HOLD_TIME_US); wait_us(600); } @@ -63,9 +68,9 @@ data |=((_spi.write(0)<< 8)&0x0000FF00); data >>= 8; data &= 0xfffffff8; - wait_us(1); + wait_us(ADS1248_HOLD_TIME_US); _cs = 1; - wait_us(1); + wait_us(ADS1248_HOLD_TIME_US); return data; } @@ -81,9 +86,10 @@ _spi.write(len-1); while(len--){ *(buff++) = _spi.write(0); - }wait_us(1); + } + wait_us(ADS1248_HOLD_TIME_US); _cs = 1; - wait_us(1); + wait_us(ADS1248_HOLD_TIME_US); } unsigned char ADS1248::readReg(unsigned char reg){ @@ -99,9 +105,10 @@ _spi.write(len-1); while(len--){ _spi.write(*(buff++)); - }wait_us(1); + } + wait_us(ADS1248_HOLD_TIME_US); _cs = 1; - wait_us(1); + wait_us(ADS1248_HOLD_TIME_US); } void ADS1248::writeReg(unsigned char reg, unsigned char val){ @@ -112,8 +119,9 @@ _start = 1; _cs = 0; _spi.write(SYSOCAL); - wait_us(1); + wait_us(ADS1248_HOLD_TIME_US); _cs = 1; + wait_us(ADS1248_HOLD_TIME_US); waitReady(); } @@ -121,8 +129,9 @@ _start = 1; _cs = 0; _spi.write(SYSGCAL); - wait_us(1); + wait_us(ADS1248_HOLD_TIME_US); _cs = 1; + wait_us(ADS1248_HOLD_TIME_US); waitReady(); } @@ -130,7 +139,7 @@ _start = 1; _cs = 0; _spi.write(SELFOCAL); - wait_us(1); + wait_us(ADS1248_HOLD_TIME_US); _cs = 1; waitReady(); }