Manual control of PSoC 6 SCB SPI Slave Select line

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
NiBu_4687336
Level 5
Level 5
5 solutions authored 50 replies posted 25 replies posted

Hi.

I'm using a CY8CPROTO-063-BLE board (CYBLE-416045-02 chip). It has no SDHC block.

One SCB SPI bus is shared between a CAN-FD controller and a simple micro-SD card. The SD card interface requires that its Slave Select (SS) line remain continuously asserted across several SPI transactions. None of the PDL or HAL APIs allow this directly.

It's easy enough to use a GPIO pin to control the SS signal, but I can find no way to prevent HAL (or PDL) from attempting to control an SS line automatically. For instance, cyhal_spi_select_active_ssel(cyhal_spi_t *obj, cyhal_gpio_t ssel) will not accept NC as its cyhal_gpio_t argument.

Is it possible to use HAL (or PDL) SPI APIs while controlling SS manually? I cannot use a second SPI interface - all SCB resources on the chip are in use.

Thanks,

-Nick

0 Likes
1 Solution
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi @NiBu_4687336 ,

Please let me know if I have understood your question correctly. You want to control only , say SS0  line connected to SD card interface manually, but you want the SS1 line connected to the CAN-FD controller to be controlled by the SPI block. If that is the case, you can use the PDL (device configurator) based approach where this is more simpler.

BragadeeshV_0-1620923066174.png

Look how in the above configuration, SS0 is not selected to anything. Therefore when want to talk to Slave0, you can set the slave select as Cy_SCB_SPI_SetActiveSlaveSelect(base_obj, CY_SCB_SPI_SLAVE_SELECT0 ) and you can manually control the SS0 GPIO. If you want to talk to the Slave1, set active slave select t0 CY_SCB_SPI_SLAVE_SELECT1 and the SPI block will control that SS1 line P10.4.

Or do you want to control each of the SS line manually through firmware (CPU)? In that case, HAL is much simpler, you can just pass NULL in the SPI init function and control each of the SS (just GPIOs) manually in firmware.

Regards,
Bragadeesh

View solution in original post

0 Likes
4 Replies
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi Nick,

If you want to control the SS line manually, then you to need pass NULL to the cyhal_spi_init() to the ssel parameter. This ensures that the SPI block doesn`t control the SS line.  

Regards,
Bragadeesh
0 Likes
NiBu_4687336
Level 5
Level 5
5 solutions authored 50 replies posted 25 replies posted

Hi @BragadeeshV.

I'm doing that, and then switching SS lines to talk to the different devices. It sounds, though, that you're saying that to manually control SS for one device, I'll have to control it manually for all devices?

I'll give it a try - thanks.

-Nick

0 Likes
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi @NiBu_4687336 ,

Please let me know if I have understood your question correctly. You want to control only , say SS0  line connected to SD card interface manually, but you want the SS1 line connected to the CAN-FD controller to be controlled by the SPI block. If that is the case, you can use the PDL (device configurator) based approach where this is more simpler.

BragadeeshV_0-1620923066174.png

Look how in the above configuration, SS0 is not selected to anything. Therefore when want to talk to Slave0, you can set the slave select as Cy_SCB_SPI_SetActiveSlaveSelect(base_obj, CY_SCB_SPI_SLAVE_SELECT0 ) and you can manually control the SS0 GPIO. If you want to talk to the Slave1, set active slave select t0 CY_SCB_SPI_SLAVE_SELECT1 and the SPI block will control that SS1 line P10.4.

Or do you want to control each of the SS line manually through firmware (CPU)? In that case, HAL is much simpler, you can just pass NULL in the SPI init function and control each of the SS (just GPIOs) manually in firmware.

Regards,
Bragadeesh
0 Likes
NiBu_4687336
Level 5
Level 5
5 solutions authored 50 replies posted 25 replies posted

Hi @BragadeeshV.

Only the SD card interface needs to be controlled manually, but I'd also prefer to continue using the HAL API, at least for now. I may need to add DMA in the future to support the SD interface, which will, I believe, require use of the PDL API. It's probably easiest initially to add manual control to all the devices and plan to switch to the PDL API at a later date.

Thanks,

-Nick

0 Likes