Skip to main content
EDuat.1
Associate II
January 22, 2021
Solved

Cannot communicate with ext SPI Flash

  • January 22, 2021
  • 3 replies
  • 1087 views

Hey guys,

I am trying to communicate with S25FL064L Cypress Flash and almost for one week I cant reach the redec ID , I checked the hardware, and communication with digital analyzer just with S25FL064L no any hardware.Tried the HAL library , checked the websites and compare with my codes, I couldn'd find a mistake, so where is my mistake now.Thank you for answers and spending time.These are codes related.

int main(void)
{
	LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG);
	LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
 
	SystemClock_Config();
	// 0xEBFF FCFF for port A
	// 0xFFFF FFFF for the other ports
// I have read some info from the users and that is why this code is below
	CLEAR_REG(CS_FLASH_GPIO_Port->MODER);
 
	MX_GPIO_Init();
	MX_SPI1_Init();
	MX_SPI2_Init();
	MX_USART1_UART_Init();
	MX_USART2_UART_Init();
	MX_ADC_Init();
	MX_RTC_Init();
	MX_I2C1_Init();
 
	LL_SPI_Enable(SPI1);
}
 
void read_Jedec_ID(uint8_t *p)
{
	LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_15);
	spi_transmit_receive(SPI1, SPI_RDID_CMD);//0x9F
 
	for (uint8_t i = 0; i < 8; i++)
	{
		p[i] = spi_transmit_receive(SPI1, 0x00);
	}
 
	LL_GPIO_SetOutputPin(CS_FLASH_GPIO_Port, CS_FLASH_Pin);
 
}
 
uint8_t spi_transmit_receive(SPI_TypeDef *SPIx, uint16_t val)
{
	uint8_t ret_val;
 
	while (!(READ_BIT(SPI1->SR, SPI_SR_TXE) == (SPI_SR_TXE)))
			;
	LL_SPI_TransmitData8(SPIx, (uint8_t)val);
 
	while (!(READ_BIT(SPIx->SR, SPI_SR_RXNE) == (SPI_SR_RXNE)))
		;
	ret_val = LL_SPI_ReceiveData8(SPIx);
 
	return ret_val;
}

This topic has been closed for replies.
Best answer by EDuat.1

Okay, it is solved.Our hardware designer draws incorrecty the MOSI-MISO pins.

3 replies

Tesla DeLorean
Guru
January 22, 2021

What STM32 part?

Show signals as observed via ​logic analyzer.

Describe the pins and interfaces, I'm not going to wade through an IOC file on my phone.

I don't understand what the MODER write does before any of the clocks or interfaces are up.​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
EDuat.1
EDuat.1Author
Associate II
January 24, 2021

Show signals as observed via ​logic analyzer.

We dont need it because I already got the value from it(Digital Discovery Digilent)

I don't understand what the MODER write does before any of the clocks or interfaces are up.​

Because I tried something unnecessarly because of I read something on the websites that someone did it and works(interesting).Just get rid of it.

EDuat.1
EDuat.1AuthorBest answer
Associate II
January 25, 2021

Okay, it is solved.Our hardware designer draws incorrecty the MOSI-MISO pins.