industrialNETworXnetx

KJD

KJD

| 01.09.2008 | 17:13 | 2 replies

RCX-SPI Timing

Hi!

I use the rcx and implemented a spi. My code looks like follows:

CONST FAR RX_SPISLAVE_SET_T atrXSpi[] = {
{ {"SYSSPI",RX_PERIPHERAL_TYPE_SPI,0},
0, /* Bus port 0 */
1, /* Chip select 0 */
RX_SPI_MODE0, /* spi mode 3 */
RX_SPI_SPEED_25_0MHz, /* Speed is 25 Mhz */
0, /* No Burst block support */
0, /* No delay between bursts */
}
};

RX_HANDLE hSpi;
rX_MemAllocateMemory(&hSpi,DRV_SPI_SIZE);
Drv_SpiIdentifySpi("SYSSPI",0,&hSpi);
Drv_SpiInitializeSpi(hSpi);
UINT8 bSendBuf[4] = { 0x44, 0x11, 0x22, 0x88 };
UINT8 bRecBuf[4];

Drv_SpiOpen(hSpi, RX_INFINITE);
Drv_SpiSlaveSelect(hSpi);
Drv_SpiSendReceive(hSpi, 4, bSendBuf, bRecBuf);
Drv_SpiSlaveDeselect(hSpi);
Drv_SpiClose(hSpi);

In princible everything works fine. But the time between the falling edge on CS and the beginning of the data transfer on MOSI is very long (1.8 us) versus the time which is needed for data transfer (1.35 us - 4 bytes). Also the time between end of data transfer on MOSI and the rising edge of CS is very long - 4.2 us.

Is this normal? Do I have made mistakes? Are there any possibilities which can perform a faster data transfer (from falling edge on CS till rising edge on CS)?

Thanks

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 02.09.2008 | 06:21

Hi KJD,

I don't think that you made a mistake in your code. It looks good. I think the "long" time comes from the operating system and should be normal.
When you need a faster access you should program the SPI register directly without using the driver functions of the OS.

KJD

KJD

| 02.09.2008 | 09:34

OK. Thank you AJ.

Login