2009-05-04 11:13 AM
Configuring SPI1
2011-05-17 04:11 AM
Hi Everyone,
I have been trying to configure the STM32F103RB SPI1 interface and my hardware is not showing the same as my Keil software simulator. The main parts of my code are... /* Set SPI to master and CPOL=1, CPHA=1 */ SPI1->CR1 = 0x0000; SPI1->CR1 |= SPI_CR1_MSTR | SPI_CR1_CPOL | SPI_CR1_CPHA; /* Set SSOE to enable */ SPI1->CR2 |= SPI_CR2_SSOE; /* Enable SPI */ SPI1->CR1 |= SPI_CR1_SPE; /* Read SPI status register */ sts = SPI1->SR; In the Keil software simulator I see my 'sts' variable = 0x0002 which shows the TX_buffer is empty as I would expect. When I run on hardware the 'sts' variable = 0x0000 and I cannot transmit any data by using a line such as (I see no activity with an oscilloscope): SPI1->DR = 0xAA55; Am I missing something really obvious? The software simulator shows I am configuring the correct register addresses so I assume it maybe a setup issue elsewhere. Any ideas and suggestion would be appreciated.2011-05-17 04:11 AM
Usual suspects in such cases are:
a) failure or incorrect enabling of specific peripheral b) failure to enable the clock for that peripheral ST's FW library provides several ''known good'' SPI as master examples - review these with emphasis to a & b above...2011-05-17 04:11 AM
In my case it was b) failure to enable the clock for that peripheral.
All working now. Thanks