Shift register UDB component: function ShiftReg_ReadData()

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

cross mob
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

Hi every one!!!

   

Can anyone help me with this code, please?

   

I'm learning to use SPI and Shift register components.
I sending 4 bytes via SPI to the Shift Register.
Theoretically each "Store pulse" at Shift Register store input, each byte is stored in FIFO out.
This does not happen. With the C code which attached, the LCD display reads @ @ @ @ instead 0x0a, 0x0b, 0x0c, 0x0d that I am sending.
This is a very trivial code, but I could send data to any port in this way.
I am using the function "ShiftReg_readData ()" to capture the bytes of FIFO out.
Is this correct? The document number 001-85014 Rev A it seems to me something confuse with

"ShiftReg_readData ()" Function.

   

I hope you can understand what is written, because I do not speak good English.
From already, thank you very much to anyone who can help me.

   

Alex

   

 

   

 

   

 

   

 

   

#include <device.h>

   

#include "project.h"

   

 

   

 

   

 

   

 

   

 

   

void main()

   

{

   

 CyGlobalIntEnable;

   

 

   

 

   

/* Start components*/

   

       LCD_A_Start();

   

       SPIM_1_Start();

   

       SPIM_1_ClearTxBuffer();          

   

       ShiftReg_1_Start();

   

 /* Display initialisation*/  

   

       LCD_A_ClearDisplay();

   

       LCD_A_Position(0u,0u);   

   

       LCD_A_PrintString("Use ReadData");

   

 

   

 

   

 

   

 

   

 

   

  /* SPIM transmit  */

   

          SPIM_1_WriteTxData(0x0au); //A

   

  /* Wait for spi_DONE bit  at Status register*/

   

           while(!(SPIM_1_ReadTxStatus() & SPIM_1_STS_SPI_DONE));

   

  /* Change Display pposition to 1,0*/

   

             Control_Reg_1_Write(1u);

   

             CyDelayUs(10u);

   

             Control_Reg_1_Write(0u); //Store A

   

            

   

  /* SPIM transmit  */

   

           SPIM_1_WriteTxData(0x0bu); //B

   

  /* Wait for spi_DONE bit  at Status register*/

   

           while(!(SPIM_1_ReadTxStatus() & SPIM_1_STS_SPI_DONE));

   

  /* Change Display position to 1,0*/

   

          

   

              Control_Reg_1_Write(1u);

   

              CyDelayUs(10u);

   

              Control_Reg_1_Write(0u); //Store B 

   

       

   

 /* SPIM transmit  */

   

         SPIM_1_WriteTxData(0x0cu); //C

   

 /* Wait for spi_DONE bit  at Staus register*/

   

         while(!(SPIM_1_ReadTxStatus() & SPIM_1_STS_SPI_DONE)); /* Change Display position to 1,0*/

   

          

   

            Control_Reg_1_Write(1u);

   

            CyDelayUs(10u);

   

            Control_Reg_1_Write(0u);// Store C    

   

           

   

/* SPIM transmit  */

   

            SPIM_1_WriteTxData(0x0du);//D

   

/* Wait for spi_DONE bit  at Status register*/

   

            while(!(SPIM_1_ReadTxStatus() & SPIM_1_STS_SPI_DONE)); /* Change Display position to 1,0*/

   

              

   

               Control_Reg_1_Write(1u);

   

               CyDelayUs(10u);

   

               Control_Reg_1_Write(0u);  //Store D

   

 

   

 

   

 /* Display  characters */

   

         

   

              LCD_A_Position(1u,0u);           

   

              LCD_A_PutChar(ShiftReg_1_ReadData()) ;

   

        

   

  

   

              LCD_A_Position(1u,1u);

   

              LCD_A_PutChar(ShiftReg_1_ReadData()) ;        

   

                                

   

      

   

              LCD_A_Position(1u,2u);

   

              LCD_A_PutChar(ShiftReg_1_ReadData()) ;    

   

        

   

      

   

               LCD_A_Position(1u,3u);

   

               LCD_A_PutChar(ShiftReg_1_ReadData()) ;   

   

  

   

                    

   

        

   

       

   

   

   

  

   

           while(1u){;}

   

    

   

  }

   

  

   

  

0 Likes
3 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked
        Please do not post C-Code only here. Better post compete project (using "Create Workspace Bundle") and attach the resulting file here. So we all can have a look at your settings to find the cause of the mis-behaveour.   
   
Bob   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked
        When trying to re-construct your project a Question arises:   
Where do you get a clock-cycle from while asserting the "Store" signal which is needed as the datasheet says.   
   
Bob   
0 Likes
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

Thank very much Bob, as usually you was right, it was about  Sifth Register clock. This trivial code is running.

   

On the other hand I downloaded the PSoCCreator 3.0 is awesome.

   

Alex

0 Likes