cancel
Showing results for 
Search instead for 
Did you mean: 

Nucleo-144 SPI?

Dick Lin
Senior
Posted on June 07, 2018 at 17:49

Hi,

I am using STM32L496 Nucleo-144 connecting SPI1 to external Adafruit MAX31865 PT100 temp sensor using breadboard with Saleae.

For some reason (I have no clue at all), I got nothing from Saleae.

One thing I kinda of curious is the the pinout. From UM1279 User manual, the pinout are

- SPI_SCK PA5

- SPI1_MISO PA6

- SPI1_MOSI PA7

- SPI1_CS PD14

While from Cube the SPI1_NSS is PA4. 

I am assuming SPI1_CS and SPI1_NSS are the same (either Chip Select or Slave Select). Just not sure which one should I follow. I did try both, no luck at all.

Why I am not seeing anything from Saleae? I would think should be a very straight forward thing.

Thanks,

Dick

10 REPLIES 10
Dick Lin
Senior
Posted on June 07, 2018 at 20:26

Figured out we need to use PA4 for NSS.    PA4     ------> SPI1_NSS

And need to change the BaudRatePrescaler to 32.

  hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;

Posted on June 11, 2018 at 18:21

Now the issue become can't get any data using HAL_SPI_TransmitReceive() function. The in_data always 0 while I am able to see the data from analyzer.

Any suggestions?

Thx

Posted on June 11, 2018 at 19:37

Got super low visibility into your code/functionality

Perhaps you're not configuring the pin properly? Clocking on the wrong edge?

SPI3?

PD14 should be viable as a GPIO chip select

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on June 11, 2018 at 19:45

I am using PA4 connecting to slave CS and SPI_NSS_HARD_OUTPUT. That's the

only way to make it working instead of using PD

GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;

GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;

HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

On Mon, Jun 11, 2018 at 10:37 AM, Clive One <st-microelectronics@jiveon.com>

________________

Attachments :

image.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HxWu&d=%2Fa%2F0X0000000azL%2Fd0v3zzeOZFgetzuDogXJp9wwPzDdOj7cxXw._.tYpc4&asPdf=false
Posted on June 11, 2018 at 20:20

Not sure of the SPI_NSS_HARD_OUTPUT functionality, STM32 parts don't do that super well.

Doing SPI on L4 using PA5/PA6/PA7 on a couple of other boards without problem, so shouldn't be inherently broken.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on June 11, 2018 at 20:37

I think we might see the issue. From the slave chip MAX31865, the CS should

go active low all the time until the transaction completed.

For the HAL_SPI_TransmitReceive() seems the CS go high in the middle of

transaction. Thx

On Mon, Jun 11, 2018 at 11:22 AM, Clive One <st-microelectronics@jiveon.com>

Posted on June 11, 2018 at 21:03

When I sending 2 bytes to slave, the CS pin go high in between.

How come it not active low all the time until over? I even manual set the

pin, doesn't seems have any control.

HAL_GPIO_WritePin( GPIOA, GPIO_PIN_4, GPIO_PIN_RESET ); // NSS1 low

HAL_StatusTypeDef status = HAL_SPI_Transmit(m_spi, (uint8_t *)out_data,

len, 10);

while( m_spi->State == HAL_SPI_STATE_BUSY )

; // wait xmission complete

HAL_GPIO_WritePin( GPIOA, GPIO_PIN_4, GPIO_PIN_SET ); // NSS1 high

Posted on June 11, 2018 at 21:20

You should be able to control placement manually, not sure what your issue is. Must obviously wait for last bit of last byte to transit the bus first.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on June 11, 2018 at 21:21

Don't configure the NSS output as an alternate-function pin (which puts it under control of the SPI module), just make it a simple GPIO.