- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Everyone,
I am using PSOC CY8C6137BZI-F54 chip for my project. I am using SPI in it. The querry is: Can I change the CPHA and CPOL of SPI on the fly during run time? For example I am using 2 Slave Select, is it possible that for 1 Slave select I use CPHA = 0 & CPOL = 0; and for 2 slave select data, I shall use CPHA 1 & CPOL 1?
I can do it taking another SPI that I am aware but I am out of GPIO's.
Please let me know if there is any workaround.
Thank You
Kevin
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi KeSh_1984591,
Yes, you should be able to do this using PDL. But this will involve you to disable and re-enable the SPI hardware.
Define two different configuration structures. One that has CPHA = 0 & CPOL = 0 and other that has CPHA 1 & CPOL 1. Specific change would between the two structure would be as follows:
cy_stc_scb_spi_config_t configA;
cy_stc_scb_spi_config_t configB;
/* Other configurations are not shown here and must be done by you */
configA.sclkMode = CY_SCB_SPI_CPHA0_CPOL0;
configB.sclkMode = CY_SCB_SPI_CPHA1_CPOL1;
if(slaveSelect1)
{
while(Cy_SCB_SPI_IsBusBusy()!=0); //Ensure that busy is idle before you disable the SCB block
Cy_SCB_SPI_Disable(); //Disable the block
Cy_SCB_SPI_DeInit(); // SCB block must be disabled before calling this funciton
Cy_SCB_SPI_Init(SPI_HW, &configA, &context); //Init Config A.
Cy_SCB_SPI_SetActiveSlaveSelect(CY_SCB_SPI_SLAVE_SELECT0); //Set the active slave select0
Cy_SCB_SPI_Enable(); //Enable block only after all configurations are done
/* Start Transfer */
}
if(slaveSelect1)
{
while(Cy_SCB_SPI_IsBusBusy()!=0); //Ensure that bus is idle before you disable the SCB block
Cy_SCB_SPI_Disable(); //Disable the block
Cy_SCB_SPI_DeInit(); // SCB block must be disabled before calling this function
Cy_SCB_SPI_Init(SPI_HW, &configB, &context); //Init config B
Cy_SCB_SPI_SetActiveSlaveSelect(CY_SCB_SPI_SLAVE_SELECT1); //Set the active slave select1
Cy_SCB_SPI_Enable(); //Enable block only after all configurations are done
/* Start Transfer */
}
Hope this helps!
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi KeSh_1984591,
Yes, you should be able to do this using PDL. But this will involve you to disable and re-enable the SPI hardware.
Define two different configuration structures. One that has CPHA = 0 & CPOL = 0 and other that has CPHA 1 & CPOL 1. Specific change would between the two structure would be as follows:
cy_stc_scb_spi_config_t configA;
cy_stc_scb_spi_config_t configB;
/* Other configurations are not shown here and must be done by you */
configA.sclkMode = CY_SCB_SPI_CPHA0_CPOL0;
configB.sclkMode = CY_SCB_SPI_CPHA1_CPOL1;
if(slaveSelect1)
{
while(Cy_SCB_SPI_IsBusBusy()!=0); //Ensure that busy is idle before you disable the SCB block
Cy_SCB_SPI_Disable(); //Disable the block
Cy_SCB_SPI_DeInit(); // SCB block must be disabled before calling this funciton
Cy_SCB_SPI_Init(SPI_HW, &configA, &context); //Init Config A.
Cy_SCB_SPI_SetActiveSlaveSelect(CY_SCB_SPI_SLAVE_SELECT0); //Set the active slave select0
Cy_SCB_SPI_Enable(); //Enable block only after all configurations are done
/* Start Transfer */
}
if(slaveSelect1)
{
while(Cy_SCB_SPI_IsBusBusy()!=0); //Ensure that bus is idle before you disable the SCB block
Cy_SCB_SPI_Disable(); //Disable the block
Cy_SCB_SPI_DeInit(); // SCB block must be disabled before calling this function
Cy_SCB_SPI_Init(SPI_HW, &configB, &context); //Init config B
Cy_SCB_SPI_SetActiveSlaveSelect(CY_SCB_SPI_SLAVE_SELECT1); //Set the active slave select1
Cy_SCB_SPI_Enable(); //Enable block only after all configurations are done
/* Start Transfer */
}
Hope this helps!
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey Bragadeesh,
Hey thank you again for helping me. I never knew this way to change the configurations. This makes PSOC6 very flexible.
Since I am new to PSOC6, I very keen to learn how to use the PSOC6 PDL. Is there any detailed documentation on how to use it on PSoC Creator? PDL just explains the functionality and not the methodology to use it.
This will be of great help to me.
And thank You again for the answers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi KeSh_1984591,
You recommend you to refer the following app notes
1. Getting Started with PSoC 6 MCU on PSoC Creator
2. PSoC 6 MCU Code Examples with PSoC Creator
https://www.cypress.com/documentation/code-examples/psoc-6-mcu-code-examples-psoc-creator
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content