Thanks it works fine today. Finally I don't use interrupt for the spi
controller because I've got an external interrupt to start the read..
I use this code (I call read_ads1252() from the EINT2 interupt) :
uchar SPI_read()
{
S0SPDR = 0xFF;
while(!(S0SPSR & 0x80));
return(S0SPDR);
}
void read_ads1252()
{
mesure = (SPI_read() << 8); //bits 1 to 8
mesure += SPI_read(); //bits 9 to 16
SPI_read(); //read bits 17 to 24 not use
}
Sebastien
--- In lpc2000@lpc2..., "Marko Pavlin (home)" <mp@...> wrote:
>
> There is no difference between read and write. Just make dummy
write if
> you want read. Look at ADC datasheet when it sends
data back? Clock
is
> allways generated by master (LPC in your case). I
am using simple
SPI
> transfer function:
>
> unsigned char spi0_transfer(unsigned long dat) {
> S0SPDR = dat; // send data
> while (!(S0SPSR & 0x80)) ; // wait for transfer completed
> return S0SPDR;
> }
>
> I am not using ISR for SPI. Can you send your ISR for SPI?
For the SPI isr I used the HITEX books SPI exemples.
>
> Marko
>
>
> sebfr74 wrote:
>
> > Hi,
> > I try to read a 24 bits A/D converter from burr brown (ADS1252)
with
> > SPI interface. The converter send value in
continue. There is data
> > ready signal before the value on the data pin. I synchronize the
read
> > with an external interrupt (P0.15/EINT2 and
MISO pin are connected
> > together). The external interrupt runs well. But i don't
understand
> > how the SPI controler work :
> > I initialize the controler, the VIC interrupt for the SPI0 (see
the
> > code below).
> > - My first problem is I don't find in the user manual what start
the
> > SPI clock for a read. In other controler
(ATMEL 89C51 for
example, a
> > 0x00 write to the data register start the
clock).
> > - The second one is I have 8 clock bit on the SCLK line just at
the
> > startup an d before my first external
interrupt (the one noramlly
who
> > start the SPI read...). I don't
understand why I have got these 8
> > clock bits ? After these clock the SPI seems to be blocked...
> >
> > Thanks for your help,
> > Sebastien
> >
> > //My initialisation code...
> > VICVectCntl0 = 0x0000002A;
> > VICVectAddr0 = (unsigned)SPI_ISR;
> > VICIntEnable = 0x00000400;
> >
> > PINSEL0 |= 0x00005500;
> > S0SPCCR = 20;
> > S0SPCR = 0x000000A0;
> >
> >
> >
> >
> >
> >
> > SPONSORED LINKS
> > Microcontrollers
> > <http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microcontrollers&w2=Microprocessor&w3=Intel
+microprocessors&w4=Pic+microcontrollers&c=4&s&.sig=mfaAujKZXA2Z_vx
re9sGnQ>
> > Microprocessor
> > <http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microcontrollers&w2=Microprocessor&w3=Intel+m
icroprocessors&w4=Pic+microcontrollers&c=4&s&.sig=9jjd2D3GOLIESVQss
LmLsA>
> > Intel microprocessors
> > <http://groups.yahoo.com/gads?t=ms&k=Intel+microprocessors&w1=Microcontrollers&w2=Microprocessor&w3Intel+microprocessors&w4=Pic+microcontrollers&c=4&s&.sig=OMnZuqMZX9
5mgutt4B-tDw>
> >
> > Pic microcontrollers
> > <http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microcontrollers&w2=Microprocessor&w3=I
ntel+microprocessors&w4=Pic+microcontrollers&c=4&s&.sig=Malspbd0T4R
q3M4Q0nHrfw>
> >
> >
> >
> > >.
> >
> >
> >
>
--- In lpc2000@lpc2..., "sebfr74" <sejacquemard@...> wrote:
>
> - My first problem is I don't find in the
user manual what start the
> SPI clock for a read. In other controler (ATMEL 89C51 for example, a
> 0x00 write to the data register start the clock).
I have not yet started my ARM SPI programs, but from the manual it
looks like a write to the SPI data register starts the transfer.
Remember that SPI is just a circular shift register with one part in
the processor (usually 8 or 16 bits) and the rest in the SPI chip. So
there are not separate reads and writes. All transfers do both.
> - The second one is I have 8 clock bit on the SCLK
line just at the
> startup and before my first external interrupt (the one noramlly who
> start the SPI read...). I don't understand why I have got these 8
> clock bits ?
SPI transfers are controlled by the number of clocks when select is
asserted, not the total number of clocks. SPI even works with a free
running clock. Maybe the clock starts before the first transfer.
After these clock the SPI seems to be blocked...
Your code has
S0SPCCR = 20;
I think you want
S0SPCCR = 0x20;
Decimal 20 puts it in slave mode instead of master mode.
-- Bob H.
Reply by sebfr74●February 20, 20062006-02-20
Hi,
I try to read a 24 bits A/D converter from burr brown (ADS1252) with
SPI interface. The converter send value in continue. There is data
ready signal before the value on the data pin. I synchronize the read
with an external interrupt (P0.15/EINT2 and MISO pin are connected
together). The external interrupt runs well. But i don't understand
how the SPI controler work :
I initialize the controler, the VIC interrupt for the SPI0 (see the
code below).
- My first problem is I don't find in the user manual what start the
SPI clock for a read. In other controler (ATMEL 89C51 for example, a
0x00 write to the data register start the clock).
- The second one is I have 8 clock bit on the SCLK line just at the
startup an d before my first external interrupt (the one noramlly who
start the SPI read...). I don't understand why I have got these 8
clock bits ? After these clock the SPI seems to be blocked...
Thanks for your help,
Sebastien
//My initialisation code...
VICVectCntl0 = 0x0000002A;
VICVectAddr0 = (unsigned)SPI_ISR;
VICIntEnable = 0x00000400;
PINSEL0 |= 0x00005500;
S0SPCCR = 20;
S0SPCR = 0x000000A0;