FX3 SPI ,How to change the CPOL and CPAH at any time?

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

cross mob
ZhaoYG
Level 1
Level 1
First reply posted First question asked Welcome!

I hope we can change the SPI  CPOL/ CPAH by a command from Host by any time . I can not find any examples like it. So i try to do it  by call CyU3PSpiSetConfig, but when I do it, the firmware will become frozen. Maybe someboby can tell me the true way. thanks!!

case SPI_SET_CPOL_LOWHIGH:
if(wIndex==0)
{
g_spiConfig.cpol = CyFalse;
}
else
{
g_spiConfig.cpol = CyTrue;
}
status = CyU3PSpiSetConfig(&g_spiConfig, NULL);
break;

 

 

0 Likes
1 Solution

Hello Zhao,

Please try the following approach when you want to change the CPOL and CPHA and let me know if it helps:

1. Stop the application: This step will involve cleaning the DMA channel, destroying the channel (if SPI is used in DMA mode) and de-initialize the SPI block.

2. After this, try configuring the SPI block again by setting the required parameters and using the API CyU3PSpiSetConfig ()

Best Regards,
Jayakrishna

View solution in original post

0 Likes
3 Replies
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello,

Please let us know your exact requirement so that we can help you better. Based on my understanding, you would like to change CPHA and CPOL on the run (i.e modify the initial configuration). Please confirm if my understanding is correct. Please correct me if my understanding is wrong.

Best Regards,
Jayakrishna
0 Likes
ZhaoYG
Level 1
Level 1
First reply posted First question asked Welcome!

Dear Jayakrishna,

Thanks for your reply,  You are right , I want to change the CPOL and CPAH when the firmware is running.  So that my firmware can adapt any SPI device with different configures (CPOL and CPAH).

Best Regards,
Zhao

0 Likes

Hello Zhao,

Please try the following approach when you want to change the CPOL and CPHA and let me know if it helps:

1. Stop the application: This step will involve cleaning the DMA channel, destroying the channel (if SPI is used in DMA mode) and de-initialize the SPI block.

2. After this, try configuring the SPI block again by setting the required parameters and using the API CyU3PSpiSetConfig ()

Best Regards,
Jayakrishna
0 Likes