Home/Support/Support Forum/No data read back in SPIWrRd() on RCM6700
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

No data read back in SPIWrRd() on RCM6700

0 votes

I tried to run the following code with SPI and communicate with MSP432 (slave). The slave will return 4 bytes back which are: 0x55, 0x0F, 0xF0, 0xC3. And I saw the MOSI and MISO signal on o'scope and the signal showing correctly. However, there is no data in dat_in when I checked the watch window (all shown 0xFF). Can you give me some suggestions? Thanks.

#define SPI_SER_B
#define SPI_CLK_DIVISOR 100
#define SPI_CLOCK_MODE 0
#define CLOCK_PORT B
#define CLOCK_BIT 0

void Test(void)
char cmd[10];
char dat_in[10];

WrPortI(PCDR, &PCDRShadow, RdPortI(PCDR) | 0x10); // initial Tx idle high
WrPortI(PCDCR, &PCDCRShadow, RdPortI(PCDCR) & 0xEF); // push-pull drive control
WrPortI(PCDDR, &PCDDRShadow, RdPortI(PCDDR) | 0x10); // output direction
BitWrPortI(PCDDR,&PCDDRShadow,0, 5); // input //
WrPortI(PCAHR, &PCAHRShadow, RdPortI(PCAHR) & 0xFC); // select PC4 TXB altenate
WrPortI(PCFR, &PCFRShadow, RdPortI(PCFR) | 0x10); // enable alternate function

BitWrPortI(PCDR, &PCDRShadow, 1, 2); // CS high


cmd[0] = 0x55;
cmd[1] = 0xF0;
cmd[2] = 0x0F;
cmd[3] = 0x3C;

BitWrPortI(PCDR, &PCDRShadow, 0, 2);

SPIWrRd(cmd, dat_in, 4);

BitWrPortI(PCDR, &PCDRShadow, 1, 2);
asked Mar 13 in Rabbit Software by andyfung New to the Community (1 point)
I also tried to use SPIWrite for transmitting a single byte command. Then using SPIRead for reading back 4 bytes data. However SPIRead also have no data read back in DestAddr.

I tried to config the register SBCR to 0x0C.
- Is this config value correct?
- Is this SBCR readable? I tried to look at the Memory Dump window at 0xD4, it shown 0x00 even after I set it to 0x0C. I created an int to try to read the value:
int temp;
WrPortI(SBCR, &SBCRShadow, RdPortI(SBCR) | 0x0C);
temp = RdPortI(SBCR);
The value of temp show 0x28 which is different with what I set and the config will be "Disable the receiver input".

Please advise.

Please log in or register to answer this question.

1 Answer

0 votes
Please make sure you have the latest Dynamic C I2C libraries. Start with any version of Dynamic C 10.72 and follow the instructions in the Git repository (https://github.com/digidotcom/DCRabbit_10) to update the libraries and samples.

I recommend trying to use the libraries to initialize the I2C peripheral and send/receive data. Take a look at the existing I2C samples to see how they work.

Let me know if you're still having trouble after looking at those samples and I'll look for possible problems with the code you posted.
answered 5 days ago by TomCollins Veteran of the Digi Community (1,268 points)