Hi All!
I'm attempting to interface with a MB90580C chip through SPI. After much testing and tinkering I do need help.
The MB90580C is connected to a VFD. The program below nearly mimics the output of MB90580C with the exception of the delay between Command and Data Bytes: the delay is off by about 0 to 0.04ms. Which leads me to my first question: is that acceptable? Does this delay matter that much; couldn't the delay be any amount of time as the VFD controller would just be looking for the clock pulses as to when to start reading data?
When testing the code on the circuit the lights on the VFD are all flickering "randomly". I attribute this to the fact that I don't have the chip select/slave select enabled/disabled when transferring data, meaning the MB90580C clock and the arduino clock are fighting and enabling/disabling bits that shouldn't be. My problem is that I can't tell from the datasheet where the CS/SS is - So this leads me to my major question: Where is the chip/slave select on the MB90580C?
I am not an engineer and my background with this stuff is that of a hobbyist (first time with clocks/data pulses, etc.) so I appreciate the guidance and learning experience.
Here is the datasheet:
MB90580C Datasheet
And here is the code:
#include <SPI.h>
//CS/SS???
const int csPin = 10;
//MB90580C gnd to gnd | GND Does it need to be connected???
//MB90580C input to digital pin 11 | MOSI
//MB90580C output to digial pin 12 | MISO
//MB90580C clock to digial pin 13 | SCK
void setup() {
SPI.begin();
SPI.setBitOrder(MSBFIRST); //MSBFIRST or LSBFIRST
SPI.setDataMode(SPI_MODE3); //CPOL = 1, CPHA = 1
//40-bit data Transfer
}
//Command Byte: 0b 1000 0000 0001 0010 1000 0000 0000 0000 1000 0000
//Data Byte: 0b 0101 1011 0111 1111 1111 1101 0001 0011 0001 0010
void loop() {
//Command Byte
//digitalWrite(csPin, LOW); //select slave
SPI.transfer(0x80); //first 8 outputs
SPI.transfer(0x12); //second 8 outputs
SPI.transfer(0x80); //third 8 outputs
SPI.transfer(0x00); //fourth 8 outputs
SPI.transfer(0x80); //fifth 8 outputs
//digitalWrite(csPin, HIGH); //de-select slave
delayMicroseconds(475);
//Data Byte
//digitalWrite(csPin, LOW); //select slave
SPI.transfer(0x5B); //first 8 outputs
SPI.transfer(0x7F); //second 8 outputs
SPI.transfer(0xFF); //third 8 outputs FD | Using FF for testing
SPI.transfer(0x13); //fourth 8 outputs
SPI.transfer(0x12); //fifth 8 outputs
//digitalWrite(csPin, HIGH); //de-select slave
delayMicroseconds(475);
}