-
1. Re: How to configure SCB_SPI clock to 24MHZ in CY8CKIT-042 poineer Kit?
NoriakiT_91 Jul 19, 2019 5:52 AM (in response to sako_4328186)The SPIM_SCBCLK is an internal clock defined and used by the SPIM component.
Its frequency is a product of the "Data rate" and the "Oversampling"
So, when the "Data rate" is set to 8Mbps and the "Oversampling" is set to 6, a 48MHz clock is desired by the SPIM component.
But it is unavailable to provide a 48MHz clock to the SPIM component because the IMO clock is set to 24MHz in this case.
Here the "Tolerance" parameter is effective. The Tolerance is set to -100% to +2% This means any clock frequency is acceptable lower than or equal to 102% of 48MHz. So, PSoC Creator selects 24MHz which is the highest clock frequency made from existing clocks.
Regards,
Noriaki
-
2. Re: How to configure SCB_SPI clock to 24MHZ in CY8CKIT-042 poineer Kit?
TaH_4345166 Jul 19, 2019 6:19 AM (in response to NoriakiT_91)Hello Noriaki,
That makes sense. Thanks for the quick response on this clock issue.
But in the case explained below, we expect the “SPIM:sclk_m” to drive at 24MHz.
But with this configuration of Data Rate = 8MBPS and Oversampling of 6, we are getting clock rate of 4MPBS as shown in below pic as Actual Data Rate I,e 4000 KBPS,
https://community.cypress.com/servlet/JiveServlet/downloadImage/2-203188-399616/GS004361.png
What are the other factors which affect the SPIM:sclk_m to drive low, like 4MPBS even though desired was 24MPBS?
Please give us some configuration, which drives SPIM:sclk_m with 24MHz.
-
4. Re: How to configure SCB_SPI clock to 24MHZ in CY8CKIT-042 poineer Kit?
TaH_4345166 Jul 19, 2019 6:51 AM (in response to NoriakiT_91)Any sample code examples available for the UDB version of "SPI Master" component?
-
5. Re: How to configure SCB_SPI clock to 24MHZ in CY8CKIT-042 poineer Kit?
MoTa_728816 Jul 20, 2019 3:49 AM (in response to TaH_4345166)Hi,
I just made one for CY8CKIT-042.
Since I'm using only 1 SPI, I connected MOSI (P2[0]) and MISO (P2[1]) to test.
Schematic
SPIM Config (1)
SPIM Config(2)
Note: Although the default buffer size is 4, as I set num to send to 8, I made Buffer Size bigger (16).
Pin assignment
main.c
==================
#include "project.h"
#include "stdio.h"
char str[128] ; /* print buffer */
void print(char *str)
{
UART_UartPutString(str) ;
}
void init_hardware(void)
{
UART_Start() ;
SPIM_Start() ;
CyGlobalIntEnable; /* Enable global interrupts. */
}
void splash(void)
{
sprintf(str, "UDB SPI(Master) Loop Back Test (%s %s)\n", __DATE__, __TIME__) ;
print(str) ;
}
#define TIMEOUT_MS 1000
#define RX_BUF_LEN 32
#define RX_BUF_LEN 32
int main(void)
{
int offset = 0 ;
int i ;
uint8_t tx_buf[RX_BUF_LEN] ;
uint8_t rx_buf[RX_BUF_LEN] ;
int tx_count, rx_count ;
int num_to_send = 8 ;
int timeout_count = 1000 ;
init_hardware() ;
splash() ;
for(;;)
{
/* prepare data to send */
for (i = 0 ; i < num_to_send ; i++ ) {
tx_buf[i] = offset + i ;
}
tx_count = num_to_send ;
/* send data */
SPIM_PutArray(tx_buf, tx_count) ;
/* wait for the data to be sent */
while(SPIM_GetTxBufferSize() > 0) {
timeout_count++ ;
if (timeout_count >= TIMEOUT_MS) {
print("SPIM Sending Timeout!\n") ;
break ;
}
CyDelay(1) ; /* wait 1ms */
}
/* receive data */
rx_count = 0 ;
while(SPIM_GetRxBufferSize() > 0) {
rx_buf[rx_count] = SPIM_ReadRxData() ;
rx_count++ ;
if (rx_count >= RX_BUF_LEN) { /* overflow! */
break ;
}
}
print("Data Sent : ") ;
for (i = 0 ; i < tx_count ; i++ ) {
sprintf(str, "%02X ", tx_buf[i]) ;
print(str) ;
}
print("\n") ;
print("Data Received: ") ;
for (i = 0 ; i < rx_count ; i++ ) {
sprintf(str, "%02X ", rx_buf[i]) ;
print(str) ;
}
print("\n\n") ;
CyDelay(2000) ; /* wait 2 sec */
offset++ ;
if (offset >= 20) {
offset = 0 ;
}
}
}
==================
Tera Term Log
moto
-
6. Re: How to configure SCB_SPI clock to 24MHZ in CY8CKIT-042 poineer Kit?
TaH_4345166 Jul 23, 2019 12:11 AM (in response to MoTa_728816)Hello Tanaka,
Thanks for the reply.
I could verify the loopback behavior and it's working fine.
But I am not getting any clock pulse on the pin-44 (P1.7) pin as configured for SCLK in this project.
Are we missing anything here?
-
7. Re: How to configure SCB_SPI clock to 24MHZ in CY8CKIT-042 poineer Kit?
MoTa_728816 Jul 23, 2019 1:17 AM (in response to TaH_4345166)Hi,
Actually it was me who was missing something.
In CY8CKIT-042, pin-44 (P1[7]) is used for AREF and connected to a capacitor,
which means that this pin is not good for high frequency signal.
But as I was doing loop back, PSoC actually did not care much about the SCLK...
Anyway, I changed the SCLK to P2[2], which is next to MISO/MOSI
Now I can observe SCLK, although this oscilloscope is not quite fast enough...
I'm sorry for the inconvenience.
moto
P.S. I wonder how I could ended up using P1[7] for SCLK... orz
-
8. Re: How to configure SCB_SPI clock to 24MHZ in CY8CKIT-042 poineer Kit?
TaH_4345166 Jul 23, 2019 4:07 AM (in response to MoTa_728816)Thanks. That worked.
Actually I had a doubt but couldn't get anything on UDB discerption.
And one more thing. From where we can get this UDB code examples? Because I can see only SCB code examples from my creator IDE!
-
9. Re: How to configure SCB_SPI clock to 24MHZ in CY8CKIT-042 poineer Kit?
MoTa_728816 Jul 23, 2019 5:50 AM (in response to TaH_4345166)Hi,
> That worked.
I'm glad hearing that!
> And one more thing. From where we can get this UDB code examples?
IMHO, Cypress Developer Community (aka here) and KBA should be the best place to search.
But as you already know, we are not always lucky enough to find an expecting sample.
In such case, what I usually do is/are
(1) Read the component datasheet, which we can open the components' catalog.
I think that the component datasheet is the most complete and reliable information for the component.
Especially it matters when there is/are difference(s) between UDB component and SCB component.
(2) Having said that still I must admit that usually I refer to the generated source itself.
So for this case, SPIM.h and SPIM.c
SPIM.h, with the header we can see what kind of APIs are available.
Then I read the SPIM.c, I like the way Cypress Programmers comment their code.
They usually list choices of parameter (defined ones), which help me a lot to write code(s).
(3) And the last but not the least, they recently opened "Community Code Examples" area.
Not only there is/are examples, I think that you can request an example there.
Well, can we call it a day?
moto
-
10. Re: How to configure SCB_SPI clock to 24MHZ in CY8CKIT-042 poineer Kit?
sako_4328186 Aug 5, 2019 11:45 PM (in response to MoTa_728816)Hi,
Thanks for the Great help..!
Everything is working fine, but here we are just following Polling mechanism means, we are not expecting any data or response from Slave, so MISO pin is not required.
As per sample code which you referred, MISO is not required and it is configured to some GPIO. we want to use same GPIO for some other purpose.
i tried to delete the pin from top design but its throughout an error.
please help us, if anything is possible as per our requirement.
Deepthi
-
12. Re: How to configure SCB_SPI clock to 24MHZ in CY8CKIT-042 poineer Kit?
TaH_4345166 Aug 6, 2019 12:35 AM (in response to MoTa_728816)Hi Tanaka,
Thanks for the reply.
In both the cases mentioned above, MISO pin will be configured but only the input varies.
But, is it possible to remove the MISO pin completely from the design so that we can use that pin for some other purpose instead of SPI data.
We require only 2 line CLK & MOSI for this SPI. IS it possible? If so, then how to remove this MISO form design?