Martha MigliacioAlex Wong
Published © GPL3+

Using the Pmod SF2 with Arduino Uno

Application notes for Pmod SF2 and Arduino Uno. In this app, data is stored at the specified address and then replayed.

BeginnerShowcase (no instructions)1 hour978
Using the Pmod SF2 with Arduino Uno

Things used in this project

Hardware components

Pmod SF2
Digilent Pmod SF2
×1
Arduino UNO
Arduino UNO
×1
Adafruit 8-channel Bi-directional Logic Level Converter - TXB0108
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Pmod SF2 and Arduino Uno Fritzing file

Fritzing file displaying the connection of the Pmod SF2 to the Arduino Uno.

Pmod SF2 and Arduino Uno Fritzing Image

Fritzing image displaying the connection between the Pmod SF2 and Arduino Uno.

Code

Pmod SF2 and Arduino Uno Code

Arduino
Using this code will store data at a specified address and then replay and display in the serial monitor.
/************************************************************************
*
* Test of the Pmod
*
*************************************************************************
* Description: Pmod_SF2
* Data is stored at the specified address and then replayed
* and displayed in the serial monitor.
*
* Material
* 1. Arduino Uno
* 2. Pmod SF2
* 3. Adafruit module TXB0108
*
************************************************************************/

#define CS 10 // Assignment of the CS pin

#include <SPI.h> // call library

int i;
int adresse=0xFF;
int donnee=0x55;
byte recu[3];
byte envoi[5];

void setup()
{
 Serial.begin(9600); // initialization of
serial communication
 SPI.begin(); // initialization of SPI port
 SPI.setDataMode(SPI_MODE0); // configuration of SPI communication in mode 0
 SPI.setClockDivider(SPI_CLOCK_DIV16); // configuration of clock at 1MHz
 pinMode(CS, OUTPUT);
 envoi[0] = adresse >> 16;
 envoi[1] = adresse >> 8;
 envoi[2] = adresse;
 envoi[3] = donnee;
 // validation écriture dans la mémoire
 digitalWrite(CS, LOW); // activation of CS line
 SPI.transfer(0x06); // write validation
 digitalWrite(CS, HIGH); // deactivation of CS line
 // effacement complet la mémoire
 digitalWrite(CS, LOW); // activation of CS line
 SPI.transfer(0xC7); // erase
 digitalWrite(CS, HIGH); // deactivation of CS line
 // écriture d'une donnée à l'adresse spécifiée
 digitalWrite(CS, LOW); // activation of CS line
 SPI.transfer(0x02); // write data a specified adress
 for (i=0;i<4;i=i+1)
    {  
    SPI.transfer(envoi[i]);
    }
 digitalWrite(CS, HIGH); // deactivation of CS line
 digitalWrite(CS, LOW); // activation of CS line
 SPI.transfer(0x04); // lock write
 digitalWrite(CS, HIGH); // deactivation of CS line
 delay(1000);
}

void loop()
{
 digitalWrite(CS, LOW); // activation of CS line
 SPI.transfer(0x03); // read data from adress
 for (i=0;i<3;i=i+1)
    {
    SPI.transfer(envoi[i]);
    }
 recu[0]=SPI.transfer(0);
 digitalWrite(CS, HIGH); // deactivation of CS line
 Serial.println(recu[0],HEX);
}

Credits

Martha Migliacio

Martha Migliacio

5 projects • 18 followers
Alex Wong

Alex Wong

14 projects • 53 followers
I work in Digilent and like creating projects
Thanks to Lextronics.

Comments