STM32F030F4 and SPI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-15 6:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-15 6:43 PM
Try again with some content/description
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-15 6:45 PM
After setting the bus IP in 1-line bidirectional data mode, the selected and Output enabled (transmit-only mode) DR register to which data is to be transmitted is in the "READ" state and it is impossible to write any data to it. I enclose part of the initialization code of the SPI bus. In this particular case, I connect the SPI screen and part of the pins intended for controlling the CS and RD. This code works on STM32F103C8B dv in several projects ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-15 6:45 PM
void SPI1_Init(void)
{
RCC->APB2ENR |= RCC_APB2ENR_SPI1EN ; //çà ïóñê òà êòèðîâà Ãèÿ SPI1
RCC->AHBENR |= RCC_AHBENR_GPIOAEN ; //çà ïóñê òà êòèðîâà Ãèÿ �?îðò À
// RCC->APB2ENR |= RCC_APB2ENR_AFIOEN ; //çà ïóñê òà êòèðîâà Ãèÿ à ëüòåðÃà òèâÃûõ ôóÃêöèé
//èÃèöèà ëèçà öèÿ ïèÃîâ äëÿ SPI1
GPIO_StructInit(&ports);
ports.GPIO_Mode = GPIO_Mode_AF;
ports.GPIO_Pin = GPIO_Pin_5|GPIO_Pin_7;
ports.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_Init(GPIOA, &ports);
//èÃèöèà ëèçà öèÿ îñòà üÃûõ ïèÃîâ
GPIO_StructInit(&ports);
ports.GPIO_Mode = GPIO_Mode_OUT;
ports.GPIO_Pin = LCD_CONT;
ports.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(LCD_CTP, &ports);
GPIO_StructInit(&ports);
ports.GPIO_Mode = GPIO_Mode_OUT;
ports.GPIO_Pin = GPIO_Pin_1;
GPIO_Init(GPIOF, &ports);
//***********************************************************************************************
SPI_StructInit(&spi);
spi.SPI_Direction = SPI_Direction_1Line_Tx;
spi.SPI_Mode = SPI_Mode_Master;
spi.SPI_DataSize = SPI_DataSize_8b;
spi.SPI_CPOL = SPI_CPOL_High;
spi.SPI_CPHA = SPI_CPHA_2Edge;
spi.SPI_NSS = SPI_NSS_Soft;
spi.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
spi.SPI_FirstBit = SPI_FirstBit_MSB;
spi.SPI_CRCPolynomial = 7;
SPI_BiDirectionalLineConfig(SPI1, SPI_Direction_Tx);
SPI_Init(SPI1, &spi);
SPI_Cmd(SPI1, ENABLE);
SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_TXE, ENABLE);
//***********************************************************************************************
//òåñòîâà ÿ ïðîâåðêà ïèÃîâ CS RS RST
CS_HIGH;
RSET_HIGH;
RS_HIGH;
CS_LOW;
RS_LOW;
RSET_LOW
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-15 6:52 PM
Sorry for the bad English, the translator is not always able to lend specificity
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-15 7:06 PM
what's happening:
SPI_SendData8 (SPI1, 0X10); // SPI1-> DR = 0X10; //*(__IO uint8_t*)&SPI1 -> DR = (uint8_t)0X10;
This command should change the BSY: Busy flag = 1 and TXE: Transmit buffer empti = 0 but this does not happen. in the simulator everything works, but in the real board and with the debug not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-15 11:47 PM
Read out the SPI control registers content and check.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-16 12:03 AM
Here, the truth is in the simulation, but with real performance it’s all the same.
RCC checked all set up as expected. I don’t even know where to look ... whether to change the microcontroller to the same one or to install the stm32f103�?b on which everything works ....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-18 7:23 PM
Hello, spent the weekend to combat this problem.
In the standard setting of the SPI bus, the required signal is present at the MOSI, MISO, CLK outputs and the bus is working, but when trying to switch the bus to the “one line TX�? mode, the DR register is locked to write. MK is working and working fine, to control changed to the same and the result has not changed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-18 8:06 PM
I have already written 3 SPI bus configuration programs:
on registers, CMSIS, HAL and it did not help to solve my problem. Registr DR - READ(ONLY)
