imx51 - SPI - receive problem
Hi All,
I am using the babbage imx51 EVK board connected with dsPIC33F micro controller (5 lines, SS, SCLK, MOSI, MISO, and SPI_RDY).
I am using the following portion of code in my driver.
static int __devinit dspic_probe(struct spi_device *spi)
{
...
spi->mode = SPI_MODE_1;
spi->bits_per_word = 8;
spi_setup(spi);
...
}
static int dspic_spi_transfer(struct spi_device *spi, struct
spi_transfer *t)
{
int ret, i;
struct spi_message m;
dev_dbg(&spi->dev, "%s: tx:\n", __FUNCTION__);
for(i = 0; i < t->len; i++) {
dev_dbg(&spi->dev, "0x%x \n", *(char *)&t->tx_buf[i]);
}
dev_dbg(&spi->dev, "\n");
mutex_lock(&spi_lock);
spi_message_init(&m);
if (enable_dma) {
t->tx_dma = can_priv.spi_tx_dma;
t->rx_dma = can_priv.spi_rx_dma;
m.is_dma_mapped = 1;
}
spi_message_add_tail(t, &m);
ret = spi_sync(spi, &m);
dev_dbg(&spi->dev, "ret = %d\n", ret);
dev_dbg(&spi->dev, "rx data: \n");
for(i = 0; i < 4; i++)
dev_dbg(&spi->dev, "%x\n", can_priv.spi_rx_buf[i]);
mdelay(10);
dev_dbg(&spi->dev, "rx data: \n");
for(i = 0; i < 4; i++)
dev_dbg(&spi->dev, "%x\n", can_priv.spi_rx_buf[i]);
dev_dbg(&spi->dev, "actual len: %x\n", m.actual_length);
mutex_unlock(&spi_lock);
return ret;
}
In the dspic side, we are running the code with CKE = 1 and CKP = 0(Serial output data changes on transition from High to low ).
Whenever I send the data, dspic has to send the data 0xD7b1 as response. When i send the data, dspic is sending the reponse correctly. I am able to probe the data (SCK, MOSI and MISO) using the CRO. I could see the data correctly in CRO.
But my driver reads the value as always zero.
Can you predict the cause of this?
Any help would be greatly appreciated.
Thanks in advance.
|