cancel
Showing results for 
Search instead for 
Did you mean: 

SPI interface at 10MHz speed: delay between bytes transmitting

jrajeev
Associate II
Posted on November 14, 2005 at 00:08

SPI interface at 10MHz speed: delay between bytes transmitting

2 REPLIES 2
jrajeev
Associate II
Posted on May 17, 2011 at 12:09

Hi,

I am trying to interface uPSD3334D Controller and SPI ADC Chip(TLC3578 from TI). I am able to communicate with ADC at less than 2.5MHz speed. When I increase the speed, from first byte and second byte a delay of more than 30uSec is coming.

I am using the code I received with ST development kit as reference. Please help. I am attaching the modified code.

Thanks.

Jose

void SPI_Init(void)

{

P4SFS0 = 0xF0;

P4SFS1 = 0xF0;

SPICON1=0x00;

SPICLKD=0x04; SPICON0=0x18;

IEA|=0x40;

IPA|=0x40;

EA=1;

}

void spiRead()

{

SPI_transfer(&INITIALIZE,0,2); //0xA0,0X00

SPI_transfer(&CONFIGURE,0,2); //0XAE, 0X42

SPI_transfer(&READ_FIFO,&RDFF_RX,16); //0XE0,0X00

}

void SPI_transfer(unsigned char *send, unsigned char *receive, unsigned char length)

{

tlength = length;

buf1 = send;

buf2 = receive;

flag1 = *buf1;

flag = 0;

endflag = 0;

while (SPISTAT & SPI_BUSY_FLAG);

SPITDR = *buf1;

buf1++;

tlen = 1;

rlen = 0;

SPICON1 |= RIE;

SPICON1 |= RORIE;

SPICON1 |= TEIE;

SPICON1 |= TIE;

SPICON0 |= TE;

SPICON0 |= RE;

}

void SPI_isr (void) interrupt SPI_VECTOR using 2

{

unsigned char status ;

status = SPISTAT;

if(status & SPI_TRANSMIT_END_FLAG)

{

while (SPISTAT & SPI_BUSY_FLAG);

SPICON1 &= (~TIE);

SPICON0 &= (~TE);

SPICON1 &= (~TEIE);

endflag = 1;

}

if(status & SPI_TI_FLAG)

{

if(tlen < tlength)

{

SPITDR = *buf1;

buf1++;

tlen++;

}

}

if(status & SPI_RI_FLAG)

{

*buf2=SPIRDR;

buf2++;

rlen++;

}

} return 0;

}

jrajeev
Associate II
Posted on May 17, 2011 at 12:09

In the code I am waiting at only following locations

while (SPISTAT & SPI_BUSY_FLAG); //to start transmission

while (SPISTAT & SPI_BUSY_FLAG); //transmit complete

I think I am not waiting anywhere else

Thanks.

Jose