EmbeddedRelated.com
Forums

LPC214x: Can we really manage the SSP (SPI mode) in interrupt mode????

Started by croquettegnu March 15, 2007
Hi All,

I'm really confused on how to deal with the SSP interrupts to manage
my SPI transfers.
There are two flags called RXIM and TXIM that allows to trig an
interrupt as soon as the TX FIFO is half empty and the Rx FIFO is half
full.
These are the only flags that can be used to generate an interrupt
(except error flags).
But I do NOT understand how to manage my transfer with such interrupts.

Indeed, here is a classical SPI transfer (8bits for example):
i) RXIM interrupt is enabled
ii) TX FIFO buffer is filled with 8 bytes
iii) the tx transfer starts
iv) Half of the RX FIFO is written (so 4 bytes)
v) RXIM is triggered, ie at least 4 bytes are received

What should I do at this step? I want once the first transfer achieved
start a new one
a) wait for end of the receive transfer in my interrupt handler?
b) send my new message in the interrupt handler?

Thanks a lot for any explications !
Frederic

An Engineer's Guide to the LPC2100 Series

> -----Original Message-----
> From: l...
> [mailto:l...]On Behalf
> Of croquettegnu
> Sent: Thursday, March 15, 2007 1:02 AM
> To: l...
> Subject: [lpc2000] LPC214x: Can we really manage the SSP (SPI mode) in
> interrupt mode????
> Hi All,
>
> I'm really confused on how to deal with the SSP interrupts to manage
> my SPI transfers.
> There are two flags called RXIM and TXIM that allows to trig an
> interrupt as soon as the TX FIFO is half empty and the Rx FIFO is half
> full.
> These are the only flags that can be used to generate an interrupt
> (except error flags).
> But I do NOT understand how to manage my transfer with such
> interrupts.
>
> Indeed, here is a classical SPI transfer (8bits for example):
> i) RXIM interrupt is enabled
> ii) TX FIFO buffer is filled with 8 bytes
> iii) the tx transfer starts
> iv) Half of the RX FIFO is written (so 4 bytes)
> v) RXIM is triggered, ie at least 4 bytes are received
>
> What should I do at this step? I want once the first transfer achieved
> start a new one
> a) wait for end of the receive transfer in my interrupt handler?
> b) send my new message in the interrupt handler?
>
> Thanks a lot for any explications !
> Frederic
>

How about this:
If RXIM fires, you may send up to another 4 bytes. Since you preloaded
the TX FIFO with 8, you have now received at least 4, then at least 4 were
sent.
If you don't have anymore data to send, then just empty the Rx FIFO.
If the RTIM interrupt fires, empty the Rx FIFO, and the transfer should
now be finished.

Good luck,

Mike
Thanks a lot Mike!
It works perfectly now even if I can't reach baudrate such as 16Mbit/s
or 24Mbit/s...

--- In l..., "Michael Anton" wrote:
>
> > -----Original Message-----
> > From: l...
> > [mailto:l...]On Behalf
> > Of croquettegnu
> > Sent: Thursday, March 15, 2007 1:02 AM
> > To: l...
> > Subject: [lpc2000] LPC214x: Can we really manage the SSP (SPI mode) in
> > interrupt mode????
> >
> >
> > Hi All,
> >
> > I'm really confused on how to deal with the SSP interrupts to manage
> > my SPI transfers.
> > There are two flags called RXIM and TXIM that allows to trig an
> > interrupt as soon as the TX FIFO is half empty and the Rx FIFO is half
> > full.
> > These are the only flags that can be used to generate an interrupt
> > (except error flags).
> > But I do NOT understand how to manage my transfer with such
> > interrupts.
> >
> > Indeed, here is a classical SPI transfer (8bits for example):
> > i) RXIM interrupt is enabled
> > ii) TX FIFO buffer is filled with 8 bytes
> > iii) the tx transfer starts
> > iv) Half of the RX FIFO is written (so 4 bytes)
> > v) RXIM is triggered, ie at least 4 bytes are received
> >
> > What should I do at this step? I want once the first transfer achieved
> > start a new one
> > a) wait for end of the receive transfer in my interrupt handler?
> > b) send my new message in the interrupt handler?
> >
> > Thanks a lot for any explications !
> > Frederic
> > How about this:
> If RXIM fires, you may send up to another 4 bytes. Since you preloaded
> the TX FIFO with 8, you have now received at least 4, then at least
4 were
> sent.
> If you don't have anymore data to send, then just empty the Rx FIFO.
> If the RTIM interrupt fires, empty the Rx FIFO, and the transfer should
> now be finished.
>
> Good luck,
>
> Mike
>