cancel
Showing results for 
Search instead for 
Did you mean: 

HAL SPI-NSS?

Sandeep Dhokne
Associate II
Posted on July 23, 2017 at 13:57

What is the use of SPI-NSS?

Is it chip select pin or something else?

shall i use external gpio pin for chip select or i can use SPI-NSS?

Please explain.....

Thank you.

5 REPLIES 5
john doe
Lead
Posted on July 23, 2017 at 16:47

yes its the slave select

Posted on July 24, 2017 at 06:40

Thank you.

SPI-NSS operate automatically?

Or need to operate it by manually (means need to write separate code for it)?

i.e is it inbuilt SPI engine line LPC2148 microcontroller?

Because i want to interface Flash Memory AT45DB041 via SPI and it is not working.

Same thing i did in

LPC2148 microcontroller but in STM32F405 I don't know what happened.

i used HAL_SPI_Transmit

and

 

 

HAL_SPI_TransmitReceive

API's.

can you please help me?

Thank you.

Posted on July 24, 2017 at 06:54

If you only intend to communicate with one slave in total, then you can use the hardware _NSS pin and have the SPI peripheral manage that pin automatically.

Otherwise you have to bit-bang the NSS (CS) pin(s) manually.

Posted on July 24, 2017 at 07:30

Thank you.

how can i send a hex command through HAL_SPI_Transmit

 

and

 

 

HAL_SPI_TransmitReceive

 

API's.

I want to send following commands,

SPI_Write(0x82);

 

SPI_Write((UCHAR)((PageId>>7) & 0xFF));

 

SPI_Write((UCHAR)((PageId<<1)|(ByteId>>8)) & 0xFF);

 

SPI_Write((UCHAR)(ByteId & 0xFF));

Because there is a character array in above API's.

Posted on July 24, 2017 at 12:45

    HAL_GPIO_WritePin( SPI2_CS1_GPIO_Port, SPI2_CS1_Pin, GPIO_PIN_RESET );

    status = HAL_SPI_TransmitReceive( &hspi2, (uint8_t *)(&txarray), (uint8_t *)(&rxarray), cnt+1, 5);

    while( hspi2.State == HAL_SPI_STATE_BUSY ) {};

    HAL_GPIO_WritePin( SPI2_CS1_GPIO_Port, SPI2_CS1_Pin, GPIO_PIN_SET );