- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Every one,
I want to begin a communication between SPI master and two slaves. I wonder how i can do "Firmware Controlled Slave Selects" or using control registers.
Looking forward for reply!
Awais
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just use two strong output pins without hardware connection named alike SS1 and SS2 (or whatever you prefer). When a transaction starts, biringing the corresponding SS-line low by issuing a SS1_Write(0) (or more readable SS1_Write(SelectSlave)) and when all data has been sent out issue a SS1_Write(1) (or SS1_Write(DeselectSlave)).
Do not forget to #define SelectSlave 0 and DeselectSlave 1.
Pitfall is: when there is still a byte or part of it in the transmit buffer de-asserting the SS will clobber the communication. So really wait for transmission completed.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just use two strong output pins without hardware connection named alike SS1 and SS2 (or whatever you prefer). When a transaction starts, biringing the corresponding SS-line low by issuing a SS1_Write(0) (or more readable SS1_Write(SelectSlave)) and when all data has been sent out issue a SS1_Write(1) (or SS1_Write(DeselectSlave)).
Do not forget to #define SelectSlave 0 and DeselectSlave 1.
Pitfall is: when there is still a byte or part of it in the transmit buffer de-asserting the SS will clobber the communication. So really wait for transmission completed.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"Is this the correct thing that you just suggested"
Nearly.
You can omit the control registers, remove the "Hardware Connection" of the pin components and directly write to the pin using
SPI_SS_Master_DAC_Write(0); // Select DAC
or
SPI_SS_Master_DigPot_Write(0);// Select DigPot
This is saving some resources.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Perfect!
One more thing Bob, If i want to do this using control register. Then in the data sheet it says "The control register is used to control the slave select output. Before starting the transfer, the control register must be written to the active slave select line, and then returned to the inactive state after the transfer has been completed." The bold sentence is making me confused. Can you elaborate it?
Looking forward for your reply!
Regards
Awais
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"Then in the data sheet it says... " Have you got a link to the datasheet?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The pin component already has got an internal buffer to store the information, so using a control register is a bit overdone. Probably Cypress choose that to make things more clear for the first-time users.
Before you start an SPI transaction bring the ss-line low to address the slave. When the transaction is complete, which you can see by examining the number of bytes received, you bring the corresponding ss-line high again. That is done by issuing a SS_Write(HiLoState).
Bob