MiniCore icon indicating copy to clipboard operation
MiniCore copied to clipboard

No separate SPDR0 SPDR1 for the ATMega328PB?

Open fxframes opened this issue 4 months ago • 2 comments

Hi, apologies if I got this wrong. I'm working on a project that uses the SPI0 pins on a 328PB as slave for initial programming and then as master for communicating with an MCP4921. I didn't realize at first that I could use SPI1 for the second purpose, but my question still stands. The SPCR register in the 328P has become SPCR0 /1 in the 328PB, but we seem to be missing definitions for the latter? This is because regardless of using pre-made libraries or direct instructions I can't seem to make the MCP4921 work so I'm trying all possibilites.

This compiles:

void SPI_MasterInit(void)
{
   /* Set MOSI and SCK output, all others input */
   DDRB = (1<<DDB3)|(1<<DDB5);
   /* Enable SPI, Master, set clock rate fck/16 */
   SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0);
}

But this doesn't:

void SPI_MasterInit(void)
{
   /* Set MOSI and SCK output, all others input */
   DDRB = (1<<DDB3)|(1<<DDB5);
   /* Enable SPI, Master, set clock rate fck/16 */
   SPCR0 = (1<<SPE0)|(1<<MSTR0)|(1<<SPR00);
}

Thanks for any insights.

fxframes avatar Feb 13 '24 09:02 fxframes