I'm working with an ATMEGA328PB and an MCP2518FD (Canbus)
The 328PB has two SPI's 0,1 and I'm using the latter
The datasheet for the MCP2518FD says it will run at 20MHz and I'm using an external clock at the same speed. I presume therefore that I don't need to set a clock divider? If so how do I do this?
Should SPR1 be removed in the SPI enable?
My Initialisation is below
DDRC |= (1 << PIN_SCK_1) ; //Set SCK as output
DDRC &= ~(1<< PIN_MISO_1); // Set MISO as input
DDRE |= (1 << PIN_SS_1) | (1 << PIN_MOSI_1); // Set Slave select for Can bus as output
// SPI Enable, Master mode
SPCR1 |= (1 << SPE) | (1 << MSTR)| (1<<SPR1);