- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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){;}
}
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Where do you get a clock-cycle from while asserting the "Store" signal which is needed as the datasheet says.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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