cancel
Showing results for 
Search instead for 
Did you mean: 

SPI Transmit only

gross
Associate II
Posted on May 05, 2015 at 13:54

Hey,

I want use the SPI interface of the STM32F407 in transmit only mode. I tried some different solutions but it did not work. Can you tell me please which commands I have to use in the SPI Init? I can not find any options for transmit only in the HAL_Driver for SPI and in the header file for spi.

Please help 🙂

Best regards

void MX_SPI1_Init(void)

{

    hspi1.Instance = SPI1;

    hspi1.Init.Mode = SPI_MODE_MASTER;

    hspi1.Init.Direction = SPI_DIRECTION_1LINE;

    hspi1.Init.DataSize = SPI_DATASIZE_8BIT;

    hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;

    hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;

    hspi1.Init.NSS = SPI_NSS_SOFT;

    hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;

    hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;

    hspi1.Init.TIMode = SPI_TIMODE_DISABLED;

    hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;

    hspi1.Init.CRCPolynomial = 0x1;

    HAL_SPI_Init(&hspi1);

}
4 REPLIES 4
gross
Associate II
Posted on May 05, 2015 at 15:50

The problem I figured out is that the HAL_SPI_Transmit function jumps into the function SPI_WaitOnFlagUntilTimeout but the TXE flag is never set to 1. The function stick in a while loop.

Can anybody help me please? The IDE I am using is Winarm (eclipse) and I am using the GCC ARM Compiler.

Thanks

Posted on May 05, 2015 at 16:43

Can anybody help me please?

 

Sorry not a HAL subscriber here. Support here is limited to those who participate.

You'll need to refine ''did not work'' a bit to understand what facet didn't actually work, and which bits did.

If the registers in the peripheral don't assert, make sure the clock to the peripheral is correctly enabled. If the pins don't function, check that they are clocked, correctly configured, and associated with the right peripheral.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pedro23
Senior
Posted on May 06, 2015 at 11:12

Take a look to my [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32F407%20discovery%20board%2c%20SPIs%20ERROR.%20Unable%20to%20get%20max%20speed%20using%20dma&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx&currentviews=21]post , it uses 3spis TX (but using dma). 

gross
Associate II
Posted on May 06, 2015 at 12:17

Hello,

I created another project with CubeMX and now it works. I don't know where the error was.

Tahnsk for reply.