Skip to main content

Posts

Showing posts from February, 2020

AFE4300 with Arduino Due

In this post, I make an experiment to use Arduino Due to control AFE4300 for measuring in BCM mode. The code based on a guy in this link from Arduino Forum https://forum.arduino.cc/index.php?topic=319141.0 However, this not work now because the SPI library now have changed to new style and really different if you want control Clock of SPI with the command SPI.setClockDevider(). Actually, if you use this function to control SPI, the clock of SCLK keep around 4Mhz and it gives incorrect data when you communicate with AFE4300. For solving it, you need to rewrite two functions writeRegister() and readRegister() as below: void writeRegister(unsigned char address, unsigned int data) { unsigned char firstByte = (unsigned char)(data >> 8); //LA CARA ES UN OCHO) unsigned char secondByte = (unsigned char)data; SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE1)); digitalWrite(SS,LOW); SPI.transfer(address); //Send 2 bytes to be written SPI.transfer(firstBy...