3 Replies Latest reply on Sep 28, 2013 10:27 AM by user_301665782

    Shift register UDB component: function ShiftReg_ReadData()

    user_301665782

      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){;}

         

          

         

        }