ok so, im an avr man and most of my electronics that have used a microcontroller have used an AVR. but recently i started to play around with i2c and SPI because i needed external GPIO to communicate with external devices which euh... needs a few pins xD
ANYWAY. after some stupidity (on my end, bit order problem) i got the MCP23008 working, which is an i2c GPIO expander. all good an well, it worked. however, the i2c limitation of the chip (1,6Mhz) was not enough for me. its to slow.
so, i got myself a few of its SPI variation (MCP23S08) but those don't seem to work for me.
out of frustrations i got out an Pro Trinket (arduino bootloader) and wrote something in arduino to test the SPI & the chip since it has the SPI library. i wanted to check wether my setup sucked, or my code was correct or not.
apparently something is wrong with my setup, but i can't seem to put my finger on what...
i dont have a oscilloscope to see what is wrong in the communication, but what it looks like (when looking at the pin state using my multimeter) is that :
- the MCP23S08 is not responding and stays in its default tristate state (pins floating +/- 0.3V)
- once in a blue moon the chip responds, but only if i set the pin im using as CS low manually? probably coincidence.
below i have attached a picture of how my setup looks like. the green wire going over the chip is a 68 resistor (just grabbed something i had on my desk. on the MCP23008 i had just used a wire for reset pin)
as for the code, keep in mind i put the high delays there to simulate me putting it low manually..
it should set the GPIO state to 0xFF , aka set all pins high but...
#include <SPI.h>
void setup() {
SPI.begin();
pinMode(9, INPUT_PULLUP);
pinMode(8, OUTPUT);
digitalWrite(8,HIGH);
delay(100);
}
void loop() {
if(digitalRead(9) == LOW)
{
digitalWrite(8,LOW);
delay(1000);
char test = SPI.transfer(0x40);
SPI.transfer(0x09);
SPI.transfer(0xFF);
delay(2000);
digitalWrite(8,HIGH);
}
}
anyone here have an idea what is going wrong?