Skip to main content
Visitor II
July 22, 2023
Question

Stm32F4xx Spi 16 bits setup warning message when compiling

  • July 22, 2023
  • 2 replies
  • 1330 views

Hello all,

I set up an SPI com with FDM, motorola, 16 bits, MSB first, 10.5 Mbits/s, low, 2 edges, and global interrupt checked.

Program:

uint16_t RxData[1];  // 16bits data 

HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, RESET);

HAL_SPI_Receive(&hspi1, RxData, 1, 100);

HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, SET);

When I compile it, I get a warning message:

../Core/Src/main.c:342:34: warning: passing argument 2 of 'HAL_SPI_Receive' from incompatible pointer type [-Wincompatible-pointer-types]
342 | HAL_SPI_Receive(&hspi2, RxData1, 1, 100);
| ^~~~~~~
| |
| uint16_t * {aka short unsigned int *}
In file included from ../Core/Inc/stm32f4xx_hal_conf.h:399,
from ../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h:29,
from ../Core/Inc/main.h:31,
from ../Core/Src/main.c:12:
../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h:671:69: note: expected 'uint8_t *' {aka 'unsigned char *'} but argument is of type 'uint16_t *' {aka 'short unsigned int *'}
671 | HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);

The warning disappeared when I compile it the second time.  Downloaded the program and worked perfectly.  Does this create intermittent problem down the road?  If it does, what is the best way to fix it?

Thank you in advance!

 

    This topic has been closed for replies.

    2 replies

    Super User
    July 22, 2023

    The warning disappeared when I compile it the second time.

    This is because this message is a warning so does not prevent creation of the object file. When you build (not compile!) the second time, the builder sees that the .o file already exists and is newer than .c, so it skips compilation and you don't see this message again.

    Usually one should not ignore warnings. Try to understand what the compiler wants to tell you, then you'll know how to fix.

    Super User
    July 22, 2023

    try to give the HAL call what it wants... uint8 pointer. (even it is 16b data )

    HAL_SPI_Receive(&hspi1, (uint8_t *) RxData, 1, 100);

    read in 

    AScha3_0-1690053905702.png

    what the call is doing...