AdvMC SECTION B (Open Source Embedded Development Board
AdvMC SECTION B (Open Source Embedded Development Board
Applications (EC-506)
The address of I2C is 7 bits long. Theoretically allows 128 I2C addresses,
however some addresses are reserved for special purposes, thus only 112
addresses are available with 7 bit scheme.
• Working:
• One device is always a master. It performs addressing
of one slave chip before the communication starts.
• SPI.beginTransaction(SPISettings(speedMaximum, dataOrder,
dataMode)) − speedMaximum is the clock, dataOrder(MSBFIRST
or LSBFIRST), dataMode(SPI_MODE0, SPI_MODE1,
SPI_MODE2, or SPI_MODE3).
SPI as master (example)
• #include <SPI.h>
• void setup (void)
• { Serial.begin(115200); //set baud rate to 115200 for usart
• digitalWrite(SS, HIGH); // disable Slave Select
• SPI.begin (); SPI.setClockDivider(SPI_CLOCK_DIV8);//divide the clock by 8 }
• void loop (void)
• {
• char c; digitalWrite(SS, LOW); // enable Slave Select
• // send test string
• for (const char * p = "Hello, world!\r" ; c = *p; p++)
• {
• SPI.transfer (c);
• Serial.print(c);
• }
• digitalWrite(SS, HIGH); // disable Slave Select
• delay(2000);
• }
SPI as Slave
• #include <SPI.h>
• char buff [50];
• volatile byte indx;
• volatile boolean process;