Other Parts Discussed in Thread: HALCOGEN, TMS470MF06607
Hello,
I'm facing a problem with SPI, the tms470 is a master and is connected with a maxim 3420E spi-usb device.
With an oscilloscope I see the data on MOSI (or SIMO), but I had to modify the autogenerate source code from codegen to make it works, since after a completed transfer, I got the bit at 1 when calling the next spiTransfer.
while(spi->TGCTRL[group] & 0x80000000U){;}
spiTransfer(spi, group);
After this modification, I got all the data I'm expecting from the external chip (I see them on oscilloscope).
My problem is that when I'm reading
BYTE rreg(BYTE reg)
{
BYTE data;
WORD regTmp,dataTmp;
regTmp = reg << 8;
//select register to read
spiSetData(spiREG1,0,®Tmp);
mySpiTransfer(spiREG1,0);
while(!spiIsTransferComplete(spiREG1,0));
//read value
spiGetData(spiREG1,0,&dataTmp);
data = dataTmp &0xFF;
return data;
}
I have always the data received 1 step before.
For example the chip answers 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80 (from oscilloscope)
but the readings I got are 0x4,0x8,0x10, ecc ecc
does anyone has any suggestions? Since the documentation on datasheet are not very clear when it comes to SPI (not on legacy mode)
Thanks!