cancel
Showing results for 
Search instead for 
Did you mean: 

standard peripheral libraries help

mahmoud boroumand
Associate III
Posted on February 18, 2018 at 12:43

hello 

can anybody help me about these code

/////////////////////////////////////////////////////////////////////////////////////////////

/* Enable SPI in Master Mode, CPOL=0, CPHA=0. */

/* Clock speed = fPCLK1 / 256 = 280 kHz at 72 MHz PCLK1 clk. */

SPIx->CR1 = 0x037C;

SPIx->CR2 = 0x0000;

/////////////////////////////////////////////////////////////////////////////////////////

this is my code below

* SPI configuration */

SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;

SPI_InitStructure.SPI_Mode = SPI_Mode_Master;

SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;

SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;

SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;

SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;

SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;

SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;

SPI_InitStructure.SPI_CRCPolynomial = 7;

SPI_Init(EVAL_SPIx, &SPI_InitStructure);

are they equal?if it not equal can tell me what  should  i change?

1 REPLY 1
Posted on February 18, 2018 at 15:09

Presuming an STM32F030 part, not looking to dig through the Reference Manual to confirm bit settings.

Would suggest you do printf('%08X %08X\n', SPIx->CR1, SPIx->CR2); type confirmation

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..