STM32F1 SPI Simpleton Implementation Fail
Hi Everyone,
This is about a HAL_SPI_Transmit() single byte transmit issue.
Attached you’ll find the CubeMX configuration project.
Below is code I added in main.c in an attempt to have a simple byte going out via SPI #2 (SPI2).
It is code with which the compiler does complain and says ‘warning: passing argument 2 of ‘HAL_SPI_Transmit’ makes pointer from integer without a cast’ at HAL_SPI_Transmit(&hspi2, pData, cnt, 10);
I follow logic, i.e. say a variable called Person between brackets as (Person) and assigning a number to is is making Person think of value and not Person becoming the value, thus Person as a pointer to a location where value is to be put. The pointer here is pData and the contents concerned located in (pData) thus where pData is pointing to as far as I am concerned. The compiler has other ideas.
/* USER CODE BEGIN 2 */
uint8_t cnt = 1;
uint8_t pData;
uint8_t TheDataItself = 0xFF;
(pData) = TheDataItself;
HAL_SPI_Transmit(&hspi2, pData, cnt, 10); // 10 is the time out value.
/* USER CODE END 2 */
At ‘HAL_SPI_Transmit(&hspi2, pData, cnt, 10);’ the compiler says ‘warning: passing argument 2 of ‘HAL_SPI_Transmit’ makes pointer from integer without a cast’.
By the /* */ comments you can imagine where I added the code in main.c.
Another question: In HAL_SPI_Transmit() pData is uint8_t of type while Size is of uint16_t type. That doesn’t make sense. How can a pointer only reach 255 while the size can go up to 65535. I don’t see any practical purpose in this.
Thanks for any advice,
Greets,
Ben
PS: SOLVED. I appropriately changed pData to &pData. Why? When looking in ST’s help file STM32F103xG HAL User Manual.chm HAL_SPI_Transmit() has pData declared as *pData.