SPI not waiting for completion

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

cross mob
HuEl_264296
Level 5
Level 5
First like given 25 sign-ins First solution authored

Hi,

   

I am using the SPI slave module on a CY8C24423A. This has been working fine for several years, but now I seem to have changed something in the SPI master, because NONE of the PSoC SPI slaves are responding to it.

   

After the chip select is detected, the PSoC loads a byte into the SPI buffer, then waits for the SPI transaction to complete:

   

    mov    A, 0x06               ; MSB First SPI mode 3       
    Call    SPIS_1_Start

    Mov    A, %10101010    ; Load a byte into the SPI
    Call    SPIS_1_SetupTxData

   

SPI_Wait:                          ; Now wait for the SPI transaction to complete
    Call    SPIS_1_bReadStatus       
    AND   A, 0x20                ;0x20 = 'SPI Done' status mask   
    jz        SPI_Wait
   

   

However, the SPI_Wait loop exits immediately, even though there no clock edges have appeared yet. I have verified this on a 'scope.

   

Any ideas why the loop might exit immediately?

   

Many thanks

   

Hugo Elias

0 Likes
8 Replies
Anonymous
Not applicable

Not the same thing as yours but I am having problems with the newer version 2_1 of SPI master. I think the newer version has some things wrong. I am using PSoC development board and using the SPI master and SPI slave just for a test without even connecting the wires externally. Everytime I write to the slave the SPI master shows the SPIM_RxBufferSize() to be 1 when there has nothing been sent back by the slave.  Is there anything else I need to set up. 

0 Likes
pushekm_21
Employee
Employee
10 likes received 5 likes given First like received

 Hi Hugo,.

   

 

   

SPI Status register gets cleared whenever you read them else they retain their value. Can you please confirm that before this transaction or loop the status register has been read once to ensure that this does not have the status of previous transaction.

   

 

   

Cheers,

   

Pushek

0 Likes
pushekm_21
Employee
Employee
10 likes received 5 likes given First like received

Ananta,

   

Irrespective of the point that wires are connected or not, when master will transmit something will be received in the Rx buffer. When wires are connected data has been properly set up, the received data will be valid else it can be any random data. You need to ensure a couple of things to debug the problem:

   

1. Whether data received is valid or not.

   

2. When exactly does the master initiate the read by sending the SCLK pulses. Does it have anything to do with you setting up the data in slave?

   

 

   

 

   

Cheers,

   

Pushek

0 Likes
Anonymous
Not applicable

I started a project with the PSoC 1. The project became larger than planned. I cannot upgrade to the PSoC 3. Can you suggest a book with examples of SPI communications? I am trying to communicate with a TI ADS1211. It is a 24 bit ADC with SPI interface.

   

I have now become a bit confused. I have seen code for PIC, Adruino and Atmel. But they have there own include libraries.

   

I am running out of time to deliver my project to production.

0 Likes
pushekm_21
Employee
Employee
10 likes received 5 likes given First like received

 Please let me know your email address, I can send you some example projects else please let us know what is the problem you are facing with SPI.

   

 

   

Best regards,
Pushek

0 Likes
Anonymous
Not applicable

Well here it is 2013 and I am revisiting SPI . I am trying to develop code for 24bit ADC IC. It is using 4 wire SPI bus. If you are still around?

   

 

   

email: pnielsen@gplains.com

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Since 2011 there have been significant changes. To mention is the capability to get a choice of (working) example projects just by a right click on the SPI component.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Or on start page using "Launch Example Browser" middle pane left.

   

 

   

Regards, Dana.

0 Likes