Well, this is somewhat embarrassing, but I'm finally frustrated enough to ask for help. I have a simple routine to read 3 bytes from the SPI. It worked just fine through months of development, and then something changed, and now it always returns zeros despite the correct data clearly present on a scope (screenshots attached). This is an MK10DX128VMP5, using the IAR tools, with the SPI routines and drivers generated by PE. What I should get is statbyte[0] = 0x40, statbyte[1] = 0x00, and statbyte[2] = 0x0B, but instead they are all 0x00.
MYSPI_ClearRxBuf();
STROBE_MISO_PutVal(1); //strobe is done with GPIO pins
STROBE_MISO_PutVal(0);
for(i=0; i<3; i++){
MYSPI_SendChar(0x00); //clock in a char
spibyte = MYSPI_RecvChar(&statbyte[i]); //get it
}
STROBE_MISO_PutVal(0);
Does anybody know what's going on? I also attached a screenshot showing the spi configuration registers.
Thank you!!!
Hi
Have you maybe overwritten the SPI-RX input pin configuration so that it doesn't see the data?
Regards
Mark
Good thought, Mark, but the pin configuration appears to be correct. I made some other changes, and now it's magically working again. I'll repost if it happens again.
Thanks,
Jonathan
Hello,
I'm having the same issue. What did you change to get MISO to work and not always report 0's? I'm using a K60D100 TWR board and trying to get SPI2 to work on PORTB(pins 20-23). Tried every example but no luck. MOSI, ,CLK and CS work fine.
Pin setup:
As a sanity check a tried grounding SIN (0x00..) and then tried tying SIN to 3.3V (0xffff...) Still read all 0's.
/* Configure PINs */
PORTB_PCR20 = (0|PORT_PCR_MUX(2)); //0x200; // Alt2 //CS
PORTB_PCR21 = (0|PORT_PCR_MUX(2)); //0x200; // Alt2 //CLK
PORTB_PCR22 = (0|PORT_PCR_MUX(2)); //0x200; // Alt2 //SOUT
PORTB_PCR23 = (0|PORT_PCR_MUX(2)); //0x200; // Alt2 //SIN
Using MQX 4.1.1 w/DMA on SPI2
Thanks,
Mark