2018-08-28 10:46 AM
Hello All,
What is the secret to enabling SPI1 on PortB GPIO? Attached code below works fine on GPIOA bits PA5 and PA7
Any ideas?
Thanks in advance,
Mike
Lifting the example straight from the reference manual....
// Configure PortA bits 5 and 7 for alternate function (spi)
GPIOA->MODER |= 0x00008800; // PortA bits 5 and 7
GPIOA->OSPEEDR |= 0x0000cc00;
SPI1->CR1 = SPI_CR1_MSTR | SPI_CR1_BR; /* (1) */
SPI1->CR2 = SPI_CR2_SSOE | SPI_CR2_RXNEIE | SPI_CR2_FRXTH | SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0; /* (2) */
SPI1->CR1 |= SPI_CR1_SPE; /* (3) */
This works perfectly.
However, using PB3 and PB5, configured similarly...
// Configure PortB bits 3, and 5 for alternate function (spi)
GPIOB->MODER |= 0x00000880;
GPIOB->OSPEEDR |= 0x00000cc0;
... I get no clock and no data. It appears the SCK line is hi-z.
2018-08-28 04:19 PM
Did you enable the GPIOB clock?
If you inspect the registers in the debugger what do you see?