2018-11-27 10:39 AM
I'm using the STM32l053R8Tx, I configured the board NUCLEO-l053R8 by STM32CubeMX and I transmitted a data for an EEPROM with the function HAL_SPI_Transmit(...); and I'm trying receive the data with this function HAL_SPI_Receive(...); but I only receive " 0xFF 'ÿ' " as data. The memory that I use is that 25lc512, I send the instructions like the datasheet reported, but I can't receive another value, Can anybody help me?
2018-11-27 11:33 AM
Check the wiring and scope the signals. Ideally hook up a logic analyzer and review what you see at the pins. If the EEPROM is non-responsive you aren't going to get any usable data. Make sure the CS (chip select) pin is operational.
Easier to help if you provide a schematic and provide code.
2018-11-28 08:38 AM
void mem_start(void)
{
HAL_GPIO_WritePin(M_CS_GPIO_Port, M_CS_Pin, GPIO_PIN_RESET);
HAL_Delay(1);
HAL_SPI_Transmit(&hspi2, &WREN, 1, 100);
HAL_GPIO_WritePin(M_CS_GPIO_Port, M_CS_Pin, GPIO_PIN_SET);
HAL_Delay(10);
}
void send_data(unsigned int addr0, unsigned int addr1)
{
mem_start();
address = 0x01;
uint8_t buffer[5];
buffer [0] = 0x02;
buffer [1] = 0x00;
buffer [2] = address;
buffer [3] = 0x03;
buffer [4] = 0x06;
HAL_GPIO_WritePin(M_CS_GPIO_Port, M_CS_Pin, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi2, buffer, 5,100);
//HAL_Delay(5);
HAL_GPIO_WritePin(M_CS_GPIO_Port, M_CS_Pin, GPIO_PIN_SET);
HAL_Delay(10);
}
void receive_data(void)
{
uint8_t buffer_in [3];
uint8_t data[3];
data [0] = 0x03;
data [1] = 0x00;
data [2] = address;
//********************* receive data *****************************
HAL_GPIO_WritePin(M_CS_GPIO_Port, M_CS_Pin, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi2, data, 3,100);
HAL_SPI_Receive(&hspi2, buffer_in, 2,100);
HAL_Delay(5);
HAL_GPIO_WritePin(M_CS_GPIO_Port, M_CS_Pin, GPIO_PIN_SET);
//********************* transmit data *************************
buffer_in [2] = buffer_in[0] | buffer_in[1];
HAL_SPI_Transmit(&hspi1, &buffer_in[2], 1,100);
HAL_GPIO_WritePin(LCLK_GPIO_Port, LAT_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(LCLK_GPIO_Port, LAT_Pin, GPIO_PIN_RESET);
}
Right, here it is the schematic (did on 'paint') and a part of my code that I use for the comunication with the EEPROM.
2018-11-28 08:49 AM
And does the signalling look right on the analyzer?
I'd perhaps use the TransmitReceive variant to send the command and dummy data, and be wary of the rising edge of the CS pin
See also SPI implementation in STM32Cube_FW_L0_V1.10.0\Drivers\BSP\STM32L0xx_Nucleo\stm32l0xx_nucleo.c
2018-11-28 09:19 AM
Sometimes when I'm using the Watch I receive the right value,: data1 = 0x30 and data2 =
2018-11-28 09:23 AM
...value, for example: data1= 0x30 and data2= 0x06, data3 = data1 | data2, sometimes I receive data3 = 0x36 'ÿ', what is mean 'ÿ'?
2018-12-03 02:34 AM
thanks so much for your answer @Community member , I was able to solve the problem.