2019-05-14 07:19 AM
Hello,
i tried to create a basic STM32CubeIDE Project for Nucleo743ZI with SPI1
At first all looks nice and smooth because i did not get an error when i use HAL_SPI_Transmit.
But i then noticed that my output pins assigned to the SPI peripheral are not working, because on the Logic / Bus monitor i can only see the signals of my (separately defined) CS Signal.
Question:
Does someone have a STM32Cube IDE Project with SPI i can use for reference.
For me it is important to have an complete IDE Project, because i wan't to understand how to use the cube mx tool to setup SPIn corttectly
Thanks in advance
Note:
I thought that i can first send "something" withoutb SPI slave connected, just to monitor signals on analyser .
In a second step i will test with ATMEL DB02 EEPROM
Thanks for your example projects in advance
Marc
2019-05-14 07:30 AM
> Does someone have a STM32Cube IDE Project with SPI i can use for reference.
There are no STM32Cube IDE Project files there still, but you can read the code for reference.
2019-05-14 07:38 AM
Hello,
thanks so far:
What are the main reasons,why at least clock signals are not send to GPIO pins ?
Whta are mayor pitfalls during configuration with cubemx, what to ckeck in generated code ?
2019-05-14 08:53 AM
Hello,
i have checked the example: @file SPI/SPI_FullDuplex_ComPolling
At first i wanted to ckeck that something is visible on the Logic / Bus analyser Logic Cube
I made some minor changes: in main.c
"
HAL_StatusTypeDef Result ;
Result = HAL_TIMEOUT;
Result = HAL_SPI_TransmitReceive(&SpiHandle, (uint8_t*)aTxBuffer, (uint8_t *)aRxBuffer, BUFFERSIZE, 5000);
switch(Result)
{
case HAL_OK:
/* Communication is completed ___________________________________________ */
/* Compare the sent and received buffers */
/* if (Buffercmp((uint8_t *)aTxBuffer, (uint8_t *)aRxBuffer, BUFFERSIZE))
{
Transfer error in transmission process
Error_Handler();
}*/
/* Turn LED1 on: Transfer in transmission process is correct */
BSP_LED_On(LED1);
/* Turn LED2 on: Transfer in reception process is correct */
BSP_LED_On(LED2);
break;
case HAL_TIMEOUT:
/* A Timeout Occur ______________________________________________________*/
/* Call Timeout Handler */
Timeout_Error_Handler();
break;
/* An Error Occur ______________________________________________________ */
case HAL_ERROR:
/* Call Timeout Handler */
Error_Handler();
break;
default:
break;
}
"
With these changes , and no slaveboard connected it looks ok.
Without the compare of send and receive buffer (can't reveice sometthing wit no connection) , it looks fine
Unfortunately the same result as i have.
What are the GPIO pins used in this example for SPI ?
I haven't found a comment in the code, which GPIO pins are used for SPI here
Can someone give me a hind, where these pins can be found
Thanks in advance
2019-05-14 11:44 AM
Hello, according to another STM32 guideline in German:
See Chapter: 10.10 SPI Bus:
I have noticed that something was missing in MC_SPIx_INIT ?
Like: __HAL_RCC_SPI1_CLK_ENABLE();
and in GPIO Init like:
/*Configure SPI Pins */
GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate=GPIO_AF5_SPI1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
unfortunately, still no output on any SPI1 Pin on Nucleo H743ZI ?
Any adwise how to handle if now error (result) by transfering spi data but no physical output on pins ?
Does someone have an working SPI example for Nucleo H743ZI SPI ?
Thanks again Marc
2019-07-25 02:45 AM
Hi,
Same problem with me concerning SPI.
I watched ST instruction video on youtube how to use SPI.
I attched a MCP23S17 IO Extender for practice.
what i did was first declare array of unit8_t with 2 elements
uint8_t SpiData[2];
Then i wanted to use IODIRA en GPIOA.
on my chip A0.A1.A2 are on o level , so adress = 0
i filled the array
SpiData[0]=0x40
SpiData[1]=0x00
this is 16 bit field selecting register 0 on the MCP23S17.
Then i Use Hal_SPI_Transmit(&hspi2,&hSpiData,2,1000);
Then i forma the SpiData again:
SpiData[0]=0x40
SpiData[1]=0x00
This is write al zero's in register 0 and make al pins GPIOA output
Then again:
Hal_SPI_Transmit(&hspi2,&hSpiData,2,1000);
When i compile this i get no compile errors but warnings about the HAL_SPI_Trnasmit, second element where &SpiData is residing.
uncomtible pointer of uin8_t, typecasted it then the warning was gone.
The result is with my logic cube data analyzer that the GPIO chip select pin for the MCP23S17 is working , but no data is send over the SPI bus.
on the youtube video they only used a uint8_t array and the HAL_SPI_Transmit function.
But no data is send over the bus.
i will place a comment on the youtube video i saw yesterday.
The link to that video is below this line.
https://www.youtube.com/watch?v=KnuAP7ga5Lw
This video clearly describes how it should work it is not looking very difficult.
BUt when i use this principle there's nothing send on the SPU bus.
It is a little bit frustrating because on a Adruino i got this up and running in 15 minutes, blinking led on a MCP23S17 chip.
Hope that someone has a solution to this.
I am new to STM32 but not new to the technology a am a electronic engineer with experience in mcu's in lthe 80's i worked with Z80 , 8000 serie and so on , the principles are not so different.
But why is it so difficult to send data over the SPI bus.
The only thing is in all the video's no where is SMT32CubeMX IDe used, because ST has purchased Attolic i use the Atollic settings so that should be right.
In the video they use KEIL and thy do not get uint8_t compile warning but STM32CubeMX IDE does.
So i do not know how to check if the data really is put into the SPI TX register and send or that the warning is messing up things.
Regards,
Ronald.
2019-07-25 06:25 AM
small update,
it is not mandatory to use & before PsiData and the warnings where gone.
still same result no data gets transmitted.
looked in debug mode in SFR and on SPI2 data register i see nothing changing.
2019-08-03 08:23 AM
Is anyone reading this community ?
i have found that the HAL_SPI_Transmit function returns HAL_Busy, it does not work.
anyone @ ST can give comment on this?
I have a Nucleo board L476RG and are getting frustrated because it does not work.
I use STm32cubemx ide
2019-08-12 09:59 PM
Finally solves it myself,
was a mix of things.
SPI bus settings.
HAL_SPI_Transmit function is blocking, use HAL_SPI_TransmitReceive instead this works.
my io extender MCP23S17 now works.
first got the bus output right with logic cube logic analyzer.
Made a little mistake GPIOA is 12h en GPIOb is 13h stated in the datasheet , but i translated that to 0x0C en 0X0D that's does not work, after fixing that i had a blinking led and finally it worked.