take the SS pin high to de-select the chip: long result2 = 0 // MOSI/SDI pin 7 HIGH => 7 Hz, best resolutionĭigitalWrite(slaveSelectPin,LOW) // take the SS pin low to select the chipĭelayMicroseconds(1) // probably not needed, only need 25 nsec delay SpiRead() - read out 4 bytes from LTC2440 chip via SPI interface Mins = (float) millis() / 60000 // elapsed time in minutes Total Looptime: +2 msec (overhead for comms) acquire 'nsamples' readings, convert to units of volts, and send out on serial portĭelay(198) // (msec). SPI.setClockDivider(SPI_CLOCK_DIV16) // system clock = 16 MHz, chip max = 1 MHz SPI.setDataMode(SPI_MODE0) // SCLK idle low (CPOL=0), MOSI read on rising edge (CPHI=0) SPI.setBitOrder(MSBFIRST) // data is clocked in MSB first SPI.begin() // initialize SPI, covering MOSI,MISO,SCK signals Serial.begin(115200) // set up serial comm to PC at this baud rateĭigitalWrite(slaveSelectPin,HIGH) // chip select is active lowĭigitalWrite(resetPin,HIGH) // reset is active low SPI_CLOCK_DIV16 gives me a 1.0 MHz SPI clock, with 16 MHz crystal on Arduino set I/O pins used in addition to clock, data in, data outĬonst byte slaveSelectPin = 10 // digital pin 10 for /CSĬonst byte resetPin = 9 // digital pin 9 for /RESETĬonst int nsamples = 5 // how many ADC readings to average together Interface between Arduino DM board and Linear Tech LTC2440 24-bit ADC
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |