cancel
Showing results for 
Search instead for 
Did you mean: 

spi EEPROM ?

vitthal muddapur
Associate II
Posted on March 01, 2018 at 13:28

HI,

i have writing data to DR register 

after that in DR register shows 0xFF

addr=0x000080;

addrHigh1 = ((addr & 0xFFFFFF)>>16);

addrHigh2 = ((addr & 0xFFFFFF )>>8);

addrHigh3 = (addr & 0xFFFFFF);

wrenInstruction = WREN;

buffer1[0] =WRITE;

buffer1[1]=addrHigh1;

buffer1[2]=addrHigh2;

buffer1[3]=addrHigh3;

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET);

HAL_Delay(5);

if(HAL_SPI_Transmit(&hspi1, &wrenInstruction,sizeof(wrenInstruction) , 10) != HAL_OK){

}

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET);

HAL_Delay(5);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET);

if(HAL_SPI_Transmit(&hspi1, buffer1, sizeof(buffer1), 10) != HAL_OK){

}

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4,GPIO_PIN_SET);

HAL_Delay(5);

if(HAL_SPI_Transmit(&hspi1, buffer2, sizeof(buffer2)-1, 10) != HAL_OK){

}

buffer1[0] =READ;

buffer1[1]=addrHigh1;

buffer1[2]=addrHigh2;

buffer1[3]=addrHigh3;

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET);

HAL_Delay(5);

if(HAL_SPI_Transmit(&hspi1, buffer1, sizeof(buffer1), 10) != HAL_OK){

}

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4,GPIO_PIN_SET);

HAL_Delay(5);

if(HAL_SPI_Receive(&hspi1,buffer2,sizeof(buffer2),100)){

}

/* USER CODE END 2 */

/* Infinite loop */

/* USER CODE BEGIN WHILE */

while (1)

{

/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */

}

/* USER CODE END 3 */

}

/* SPI1 init function */

static void MX_SPI1_Init(void)

{

/* SPI1 parameter configuration*/

hspi1.Instance = SPI1;

hspi1.Init.Mode = SPI_MODE_MASTER;

hspi1.Init.Direction = SPI_DIRECTION_2LINES;

hspi1.Init.DataSize = SPI_DATASIZE_8BIT;

hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;

hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;

hspi1.Init.NSS = SPI_NSS_SOFT;

hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256;

hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;

hspi1.Init.TIMode = SPI_TIMODE_DISABLE;

hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;

hspi1.Init.CRCPolynomial = 7;

if (HAL_SPI_Init(&hspi1) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

}

I have configure SPI as FULL_DUPLEX_MASTER in stm32L0 with EEPROM

i have writing data to DR register 

after that in DR register shows 0xFF

0 REPLIES 0