I have a CAN BUS Shield from SparkFun
and am talking to it from a Propeller project board, trying to make something that will log diagnostic messages to an SD card so I look at them offline. I'm interfacing with the MCP2515 using SPI and have code written using PropWare and although I haven't actually plugged it into a car yet the library does seem to be talking to the chip and I can send messages in loopback mode and get them back - everything seems golden up to this point.
But, when I add logging to the SD card to the setup, all interactions with the MCP2515 start returning errors after the first call to fopen() to open the file to start logging.
For the SD card I'm using one of these OSEPP shield things
The voltages are a bit interesting, as the CAN BUS Shield and the OSEPP SD shield both require 5v power and I have a separate regulator and capacitor for each to give the stable power. (At first I thought that maybe using the SD card was causing a power dip and browning out the MCP2515, which I guess it still possible but I don't see how.)
The basic connections are: Prop pins 0-3 are SPI for SD, connected directly; Prop pins 13-16 are SPI for MCP2515 with a 2k resistor in series on the MISO pin (and this has worked and I confirmed I get messages back from the chip with this setup).
And the offending snippet of code (C++) looks like:
// THIS ALWAYS WORKS
int sdret = sd_mount(
// PropWare setup for MCP2515 SPI
const SPI spi(MOSI, MISO, SCLK);
MCP2515 can(spi, CS);
// IF I COMMENT THIS LINE OUT THINGS WORK FINE, OTHERWISE THE can.start() BELOW ERRORS
FILE* fp = fopen("proplog.txt", "a");
I haven't looked at the raw bits/signal that the MCP2515 returns after it starts freaking out, which I will do as soon as I can, but I'm guessing it's either gibberish or all the same bit - i.e. the chip is not in a valid state.
Does anyone know what I might be missing here? Kinda stumped.