I need help here, im using an atmega328p, the current design for my project has been working great.
I need to add can functionality and the connections for the spi slaves are confusing me.
I was going to run the Heltec 0.96' ssd1306 oled and the MCP2515 as SPI slaves.
The connections for the oled are confusing me. Could somebody please help me wire these 2 devices as spi slaves?
PLEASE NOTE the pin assignments in the code are the arduino pin numbers.
Yes. SPI is a serial bus. Each device is wired to the same MOSI, MISO and SCK signals. The only signal that isn't shared is SS. Each device has its own SS signal. The arduino pin that is connected to the device SS pin is usually specified when you call the .begin() function for the device.
Yes but here is no MISO pin being used on the oled?
Its only using MOSI and SCK. And the pin assignments in the code are different. The MOSI pin i thought should be pin 15 but its actually running on pin 13.
Pin 15 is assigned to D/C.
Yes that is correct, nothing needs to be read from the display.
Can SPI still be used if the LCD does not need a MISO. Just connect the MOSI, SCK and SS to the OLED and the MOSI, MISO, SCK and SS1 to the MCP2515?
Ok, I think I have it figured. Any chance you could have a look at my schematic and see if I have missed anything?
Read something about pullup resistors etc.
PM me if you like because I am happy to financially compensate you for your time and help.
Your SPI connections look ok. I assume that your OLED pins are correct.
Regarding pullup resistors, I don't think that they are needed for an SPI bus, but somebody more knowledgeable may be able to confirm this. They are required when using an I2C bus, which is where you may have come across the term.
If you put pull up resistors on your CS1 & CS2 signals, then that will ensure that the SPI devices don't accidentally get selected when programming the 328p. During programming the 328p is held in reset (i think!) which means that your CS pins float. The resistors take care of that.