7 segemnt com-11441 not displaying correctly when combined with other SPI devices

I have a 7 segment COM-11441 display which works fine when using the demo code shown below

/*
 11-2-2012
 Spark Fun Electronics
 Nathan Seidle
 
 This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
 Serial7Segment is an open source seven segment display. 
 This is example code that shows how to send data over SPI to the display.
 
 For more information about the commands, be sure to visit:
 http://github.com/sparkfun/Serial7SegmentDisplay/wiki/Special-Commands
 
 To get this code to work, attached an OpenSegment to an Arduino Uno using the following pins:
 Pin 10 on Uno (CS) to CS on OpenSegment
 Pin 11 to MOSI
 Pin 12 to MISO
 Pin 13 to SCK
 VIN to PWR
 GND to GND
*/

#include <SPI.h>

int ssPin = 10; //You can use any IO pin but for this example we use 10

int cycles = 0;

void setup() 
{
  //-------- SPI INITIALIZATION
  pinMode(ssPin, OUTPUT);
  digitalWrite(ssPin, HIGH); //By default, don't be selecting OpenSegment

  Serial.begin(9600); //Start serial communication at 9600 for debug statements
  Serial.println("OpenSegment Example Code");

  SPI.begin(); //Start the SPI hardware
  SPI.setClockDivider(SPI_CLOCK_DIV64); //Slow down the master a bit

  //Send the reset command to the display - this forces the cursor to return to the beginning of the display
  digitalWrite(ssPin, LOW); //Drive the CS pin low to select OpenSegment
  //---------------------
  SPI.transfer('v'); //Reset command

}

void loop() 
{
  cycles++; //Counting cycles! Yay!
  Serial.print("Cycle: ");
  Serial.println(cycles);
  
  spiSendValue(cycles); //Send the four characters to the display
  
  delay(1); //If we remove the slow debug statements, we need a very small delay to prevent flickering
}

//Given a number, spiSendValue chops up an integer into four values and sends them out over spi
void spiSendValue(int tempCycles)
{
  digitalWrite(ssPin, LOW); //Drive the CS pin low to select OpenSegment

  SPI.transfer(tempCycles / 1000); //Send the left most digit
  tempCycles %= 1000; //Now remove the left most digit from the number we want to display
  SPI.transfer(tempCycles / 100);
  tempCycles %= 100;
  SPI.transfer(tempCycles / 10);
  tempCycles %= 10;
  SPI.transfer(tempCycles); //Send the right most digit

  digitalWrite(ssPin, HIGH); //Release the CS pin to de-select OpenSegment
}

but when I combine it with another SPI device the display is not showing the correct characters; following is the code I want to use

 Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
  7_6_2022 Started file for SKEET COUNTER using EAGLE BOARD "RECEIVE_5_STAND_COUNTER_REV2" FOR SPI
           using SPI code example down loaded from SPARKFUN website
  7_7_2022 - aDDED ADAFRUIT FRAM MEMORY BREAKOUT PART#1897 
  7_10-2022 - this is working but display values are not correct.
  7-13-2022 - Added FRAM code from John Wasser.
  7/26/2022 - Changed EEPROM library to EEPROM_SPI_WE 
  7/27/2022 - Changed SPI code to use PICKLE_sketch_jula      
 ****************************************************/
#include <SPI.h> // Include the Arduino SPI library
#include <EEPROM_SPI_WE.h>                            //WE

// Define the SS pin
//  This is the only pin we can move around to any available
//  digital pin.
const int ssPin = 10;           //7 segment LED

const int csPin = 14; // WE Chip select pin
EEPROM_SPI_WE myEEP = EEPROM_SPI_WE(csPin);     //WE 

int t_count = 0;

int high_pin = 5;
int low_pin = 3;
int both_pin = 6;
int reset_pin = 8;


int high;
int low;
int both;
int reset_p;
byte btst[4];

void setup() 
{
  // -------- SPI initialization
  pinMode(ssPin, OUTPUT);  // Set the SS pin as an output
  digitalWrite(ssPin, HIGH);  // Set the SS pin HIGH
  SPI.begin();  // Begin SPI hardware
  SPI.setClockDivider(SPI_CLOCK_DIV64);  // Slow down SPI clock
  digitalWrite(ssPin, LOW);
  // --------

  Serial.begin(9600);

  if(myEEP.init()){
    Serial.println("EEPROM connected");
  }
  else{
    Serial.println("EEPROM does not respond");
    while(1);
  }
  // You can change the SPI clock speed. The default of is 8 MHz
  //myEEP.setSPIClockSpeed(4000000); // use AFTER init()!
  
  //* Select the page size of your EEPROM.
   //* Choose EEPROM_PAGE_SIZE_xxx,  
   //* with xxx = 16, 32, 64, 128 or 256
  // *
  myEEP.setPageSize(EEPROM_PAGE_SIZE_32);

  // Clear the display, and then turn on all segments and decimals
  clearDisplaySPI();  // Clears display, resets cursor

  Serial.print("t_count HEX = "); Serial.println(t_count,HEX);
  Serial.print("t_count BIN = "); Serial.println(t_count,BIN);
  Serial.print("t_count DEC = "); Serial.println(t_count,DEC);
  
  // Clear the display before jumping into loop
  clearDisplaySPI();

  //readEEProm();

  Serial.print("Starting t_count = ");Serial.println(t_count);
  Serial.print("t_count HEX = "); Serial.println(t_count,HEX);
  Serial.print("t_count BIN = "); Serial.println(t_count,BIN);
  Serial.print("t_count DEC = "); Serial.println(t_count,DEC);

  spiSendValue(t_count);
  
  pinMode(high_pin,INPUT);
  pinMode(low_pin, INPUT);
  pinMode(both_pin, INPUT);
  pinMode(reset_pin, INPUT_PULLUP);

  //Send the reset command to the display - this forces the cursor to return to the beginning of the display

  SPI.transfer('v'); //Reset command

  Serial.println("File name = SKEET_7_5_2022_SPI_FRAM_E");
  Serial.print("COUNT = ");
  Serial.println(t_count);
  
  delay(1000);
}

void loop() 
{
  high =digitalRead(high_pin);
  if (high == HIGH)
  {
    Serial.println("high_pin");
    t_count = t_count + 1;
    Serial.print("HIGH COUNT = ");
    Serial.println(t_count);
    Serial.println(t_count);
    spiSendValue(t_count); //Send the four characters to the display    
    sendEEProm();     
    delay(1000);
  }
  
  low = digitalRead(low_pin);
  if (low == HIGH)
  {
    Serial.println("low_PIN");
    t_count = t_count + 1;
    Serial.print("LOW COUNT = ");
    Serial.println(t_count);  
    spiSendValue(t_count); //Send the four characters to the display     
    sendEEProm();     
    delay(1000);      
  }

  both =digitalRead(both_pin);
  if (both == HIGH)
  {
    Serial.println("both_pin");
    t_count = t_count + 2;
    Serial.print("BOTH COUNT = ");
    Serial.println(t_count);
    spiSendValue(t_count); //Send the four characters to the display   
    sendEEProm();  
    delay(1000);     
  }

  reset_p =digitalRead(reset_pin);
  if (reset_p == LOW   )
  {
    Serial.println("reset_pin");
    t_count = 0;
    spiSendValue(t_count); //Send the four characters to the display    
    sendEEProm();
    delay(1000);     
  }
}

void spiSendValue(int tempCycles)
{
  clearDisplaySPI(); 
  Serial.println("At spiSendValue");
  digitalWrite(ssPin, LOW); //Drive the CS pin low to select OpenSegment
  Serial.print("tempCycles, BIN = "); Serial.println(tempCycles, BIN);
  Serial.print("tempCycles, HEX = "); Serial.println(tempCycles, HEX);
  SPI.transfer(tempCycles / 1000); //Send the left most digit
  tempCycles %= 1000; //Now remove the left most digit from the number we want to display
  SPI.transfer(tempCycles / 100);
  tempCycles %= 100;
  SPI.transfer(tempCycles / 10);
  tempCycles %= 10;
  SPI.transfer(tempCycles); //Send the right most digit

  digitalWrite(ssPin, HIGH); //Release the CS pin to de-select OpenSegment
}

void sendEEProm()
{
  myEEP.put(10, t_count); // write an integer to EEPROM address 10  
  Serial.print("sendEEprom READ = ");
  Serial.println(t_count);
}

void readEEProm()
{
   myEEP.get(10, t_count);
  Serial.print("raedEEProm = ");
  Serial.println(t_count);    
}

// Send the clear display command (0x76)
//  This will clear the display and reset the cursor
void clearDisplaySPI()
{
  digitalWrite(ssPin, LOW);
  SPI.transfer(0x76);  // Clear display command
  digitalWrite(ssPin, HIGH);
}

// Set the displays brightness. Should receive byte with the value
//  to set the brightness to
//  dimmest------------->brightest
//     0--------127--------255
void setBrightnessSPI(byte value)
{
  digitalWrite(ssPin, LOW);
  SPI.transfer(0x7A);  // Set brightness command byte
  SPI.transfer(value);  // brightness data byte
  digitalWrite(ssPin, HIGH);
}

// Turn on any, none, or all of the decimals.
//  The six lowest bits in the decimals parameter sets a decimal 
//  (or colon, or apostrophe) on or off. A 1 indicates on, 0 off.
//  [MSB] (X)(X)(Apos)(Colon)(Digit 4)(Digit 3)(Digit2)(Digit1)
void setDecimalsSPI(byte decimals)
{

  digitalWrite(ssPin, LOW);
  SPI.transfer(0x77);
  SPI.transfer(decimals);
  digitalWrite(ssPin, HIGH);
}
 The following is an example of  t_count input and the DISPLAY output display but these are not always the same.
t_coun = 0, DIsplay = 1111
t_count=1, Display = 3113
t_count=3, Display = 1513
t_count=4, Display = 7517

I have tried different EEPROMS, FRAM etc and several codes but the result is always the same.

Help appreciated.

Bill

To use 2 SPI devices on the same bus you need to use the CS pin and code to select which device you are controlling; google/youtube for examples :smiley:

I am using different pins and code for the two devices, 7 segment is on pin 14 and eeprom(FRAM) is on pin 10. When I write to the display I call “digitalWrite(ssPin, LOW);” and after running the write code I call for “digitalWrite(ssPin, HIGH);”

The same code works when I use a OLED display(minor code changes used).

The following is an example of t_count input and the DISPLAY output display but these are not always the same.

t_coun = 0, DIsplay = 1111

t_count=1, Display = 3113

t_count=3, Display = 1513

t_count=4, Display = 7517

I have tried different EEPROMS, FRAM etc and several codes but the result is always the same.

Any help appreciated . Does anyone else have experience using the SPARKFUN SPI 7 segment display being wued with other SPI devices?

Bill

I am using different pins and code for the two devices, 7 segment is on pin 14 and eeprom(FRAM) is on pin 10

Not according to the code you posted. Check that, and your wiring, again.

Have you made sure that the EEPROM library example code works with your setup, after setting the CS pin to 14?

Keep in mind that on AVR-based Arduinos, for SPI to work, pin 10 must be declared OUTPUT, even if you use a different pin for CS (and that pin must also be declared OUTPUT).

I’m not clear about your comment “Not according to the code you posted. Check that, and your wiring, again.”. Could you please clarify.

Pin 10 is declared as output for display and "set HIGH and LOW " are declared when writing to display.

Pin 14 is configured in the EEPROM_SPI_WE library and are not required in the setup code. The EEPROM_SPI_WE is available at https://wolles-elektronikkiste.de/en/ee … pi-eeproms.

I have tried several eeprom librarys, eeproms and code combinations and the result is always the same. The sparkfun COM-11441 series of 7 segment display are the only ones I can find that will work on SPI. there are several OLED dispalys available and they work fine.

Appreciate your help.

Thanks

Bill