Configuring SPI1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2009-05-04 11:13 AM
Posted on May 04, 2009 at 20:13
Configuring SPI1
This discussion is locked. Please start a new topic to ask your question.
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 4:11 AM
Posted on May 17, 2011 at 13:11
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.Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 4:11 AM
Posted on May 17, 2011 at 13:11
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...Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 4:11 AM
Posted on May 17, 2011 at 13:11
In my case it was b) failure to enable the clock for that peripheral.
All working now. Thanks