- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello people, here is my problem. I'm trying to interface the MAX31856 with the PSoC5. This chip communicates through an SPI Interface. I simply want to read its registers, I've already configured the SPI module and I'm printing the data in a LCD Display. My issue is that instead of showing me only the particular regiter i'm adressing, the display starts to show me secuentialy the data in all the registers one by one. Just to be clear i'm an armateur. Here is my code:
#include <project.h>
#include <cypins.h>
#define CJHF 0x03 //the register that i want to read
uint8 x;
int main(void)
{
LCD_Start();
Clock_Start();
CyGlobalIntEnable;
LCD_Position(0u,0u);
for(;;)
{
Pin_CS_Write(1);
CyDelay(1);
Pin_CS_Write(0);
SPIM_WriteTxData(0x01);
x = SPIM_ReadRxData();
Pin_CS_Write(1);
CyDelay(1);
LCD_PrintHexUint8(x);
CyDelay(500);
}
}
Solved! Go to Solution.
- Labels:
-
PSoC 5 Device Programming
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One error i can see is:
You do not wait for SPIM_WriteTxData() has successfully transmitted the data.
You could wait until there is data in the read buffer by waiting until SPIS_GetRxBufferSize() returns > 0.
The SPI interface is fast, but a bit complicated to handle: there is no explicit SPI_Read function. instead you have to send a dummy byte to receive one from the slave.
For every bit (byte) the SPI interface gets, one bit (byte) is returned immediately. When the very first byte is sent, the interface does not "know" yet what to answer, so a dummy byte is returned which should be skipped.
SPI has no read command, so you must send dummy bytes to retrieve the information wanted.
A pitfall is the select line, which is automatically taken low when a byte is sent. When the buffer is empty it is taken high again. This can lead to interface errors when the byte sequence is not provided fast enough resulting in ss-line glitches.
It is always easier to help when you post your complete project so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One error i can see is:
You do not wait for SPIM_WriteTxData() has successfully transmitted the data.
You could wait until there is data in the read buffer by waiting until SPIS_GetRxBufferSize() returns > 0.
The SPI interface is fast, but a bit complicated to handle: there is no explicit SPI_Read function. instead you have to send a dummy byte to receive one from the slave.
For every bit (byte) the SPI interface gets, one bit (byte) is returned immediately. When the very first byte is sent, the interface does not "know" yet what to answer, so a dummy byte is returned which should be skipped.
SPI has no read command, so you must send dummy bytes to retrieve the information wanted.
A pitfall is the select line, which is automatically taken low when a byte is sent. When the buffer is empty it is taken high again. This can lead to interface errors when the byte sequence is not provided fast enough resulting in ss-line glitches.
It is always easier to help when you post your complete project so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please follow the way I showed to create a workspace bundle, do not use your own compress functions.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content