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

AIROC™ Bluetooth Forum Discussions

NXTY_Tatebayasi
Level 3
Level 3
10 questions asked 10 likes given 10 replies posted

Hi, Community,


I am trying to check the operation of SPI Master only on CYBLE-012011-EVAL board.

I am referring to @MotooTanaka 's  program for PSoC4.

https://community.infineon.com/t5/PSoC-4/How-to-configure-SCB-SPI-clock-to-24MHZ-in-CY8CKIT-042-poin...

However, in the Top design view, the SPI component m_miso is an error and I cannot build.

The error message is : Terminal "m_miso" requires connection when it is visible.

What should I do to resolve this error?

 

Best Regards,

Chihiro Tatebayashi

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Hi,

I just created an empty project for CYBLE-012011.

I modified the SCB1 to SPIM.

Although no code has been written,  the project is compile-able.

So please start with this project and port the SPI part from the example to meet your requirement.

moto

View solution in original post

0 Likes
5 Replies
MotooTanaka
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Hi,

I just created an empty project for CYBLE-012011.

I modified the SCB1 to SPIM.

Although no code has been written,  the project is compile-able.

So please start with this project and port the SPI part from the example to meet your requirement.

moto

0 Likes

Hi,  Tanaka - san

Thank you for reply.
I tried to SPI master project , and I can built.
The C code has been adapted from your previous work. Thank you for providing us with a valuable program.
 
But, I faild recieved Tx data.
I consider reasons that m_miso always level 0.
The approach of connecting m_miso and m_mosi could not be built due to an error.
 
I'm almost done with the loopback program, so I'll try to figure out how to make it possible to receive Tx data.
 
Best Regards,
Chihiro Tatebayashi
 
NXTY_Tatebayasi_0-1671424704611.png

 

NXTY_Tatebayasi_1-1671424726468.png

 

=========================Incomplete program===========================

#include "project.h"
#include "stdio.h"

#define TIMEOUT_MS 1000
#define TX_BUF_LEN 32
#define RX_BUF_LEN 32

char str[128];
void print (char *str)
{
UART_UartPutString(str);
}

void init_hardware(void)
{
CyGlobalIntEnable;
UART_Start();
SPIM_Start();
}

void splash(void)
{
sprintf(str, "SPIM Loop Back Test (%s %s)\n", __DATE__, __TIME__ );
print(str);
}


int main (void)
{
int offset = 0 ;
int i ;
uint8_t tx_buf[TX_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(;;)
{
for (i = 0 ; i < num_to_send ; i++ ) {
tx_buf[i] = offset + i ;
}
tx_count = num_to_send ; /* send data*/

SPIM_SpiUartPutArray(tx_buf,tx_count);

while(SPIM_SpiUartGetTxBufferSize() > 0)
{
timeout_count++;
if(timeout_count >= TIMEOUT_MS)
{
print("SPIM Sending Timeout!\n\r");
break ;
}
CyDelay(1);
}

/*recive data*/
rx_count = 0;

while(SPIM_SpiUartGetRxBufferSize() > 0)
{
rx_buf[rx_count] = SPIM_SpiUartReadRxData();
rx_count++;
if(rx_count >= RX_BUF_LEN)
{
break;
}
}

print("Data Sent: ");
for(i = 0; i < tx_count ; i++)
{
sprintf(str, "%02X ", tx_buf[1]);
print(str);
}
print("\n\r");

print("Data Recieved: ");

for ( i = 0; i < rx_count; i++){
sprintf(str, "%02X", rx_buf[1]);
print(str);
}
print("\n\r");

CyDelay(2000);
offset++;
if(offset >= 20)
{
offset = 0;
}
}
}

0 Likes

Hi,

In your schematic, MISO seems to be connected to a constant "0".

For a loopback test, how about remove the constant and connect MISO to MOSI in the schematic?

So that you don't have to modify the hardware.

And if loopback test works, you should bring the MISO pin to the external pin for real data receiving.

moto

0 Likes

Hi,  Tanaka - san

Thank you for reply and advice.
I tried tying m_miso and m_mosi together but got an error.
I am thinking that I need to implement a mechanism in the C code to toggle the m_miso input, but I can't think of a good way to do it.
 
Best Regards,
Chihiro Tatebayashi
 

NXTY_Tatebayasi_0-1671495848719.png

 

0 Likes

Hi,

When MISO has input source from MOSI, it should not be connected to a pin.

So pleaset test without MISO pin.

Or delete wire between MOSI and MISO, then connect MOSI and MISO using external Pins with external jumper wire.

moto

0 Likes