2020-12-30 03:09 AM
Recently, I've been worked with the esp8266 and stmf407 discovery board.
I used stm32f407 (master), and connect to esp8266 (slave) via SPI
However, the package I got always missed 1 package. To be more specific, I've tried to send some uint8_t dummy datas, but all the results i got always had a missing part.
Arduino code in esp8266 :
uvision code :
void StartDefaultTask(void const * argument)
{
/* USER CODE BEGIN 5 */
/* Infinite loop */
for(;;)
{
xSemaphoreTake(DeliverHandle,portMAX_DELAY);
xSemaphoreGive(DeliverHandle);
osDelay(20);
}
}
void StartTask02(void const * argument)
{
/* USER CODE BEGIN StartTask02 */
/* Infinite loop */
uint8_t SPI_data[4]={0x01,0x02,0x03,0x04};
for(;;)
{
xSemaphoreTake(DeliverHandle,portMAX_DELAY);
//ss low
WPC_GPIO_Write_Pin(GPIOA,GPIO_PIN_15, 0x00); //CS = 0
//spi transmit
HAL_SPI_Transmit(&hspi2,SPI_data,4,1000); //Send data
//ss high
WPC_GPIO_Write_Pin(GPIOA,GPIO_PIN_15, 0x01); //CS = 1
}
osDelay(20);
xSemaphoreGive(DeliverHandle);
/* USER CODE END StartTask02 */
}
}
// I sent SPI_data[4]={0x01,0x02,0x03,0x04} through stm32f407 (master)
// esp8266(slave) debugging return from Arduino
// Nevertheless, the result i got is {0x00, 0x04, 0x03, 0x02}
Solved! Go to Solution.
2020-12-30 06:13 AM
The code you're using to send SPI is fine.
The bytes are reversed because the Arduino stores them blindly as they are received and then reads them back in little-endian.
i'm pretty sure the first byte (0x01) is lost because it indicates the status register, although it's quite hard to trace the logic in the Arduino code.
2020-12-30 06:13 AM
The code you're using to send SPI is fine.
The bytes are reversed because the Arduino stores them blindly as they are received and then reads them back in little-endian.
i'm pretty sure the first byte (0x01) is lost because it indicates the status register, although it's quite hard to trace the logic in the Arduino code.
2021-01-04 07:05 PM
Thanks , you give me a big hand.