Content originally posted in LPCWare by Powerfreak on Sun Nov 11 08:24:30 MST 2012
Hi Rob,
thanks for your information.
So this means, that I do have to poll the busy-flag... ok.
Please give me some hints again:
I wanted to speed up the SPI transfere. (all values at 18MHz SPI-clock rate and 72MHz CPU-clock)
Background: I thought, that the eg. LPC1313 has a 8 stage buffer (according datasheet) and/but I had to learn, that I cannot fill this 8 stage buffer as I wish to do... NO, I had to check if the buffer is full " /* as long as TNF bit is set (TxFIFO is not full), I can always transmit */ while ( !(SSP0SR & SSPSR_TNF) ); " (By the way: this "while" costs app 120ns in average, so I don't care)
Question1: the FIFO is 8x16 bytes long. If I do know I will be within this range, do I really need to check of the FIFO is full?
I assume no (had no faults during test for 8 Bytes)
Question2: Is the size of the FIFO only 8x16bit or can I use it as 16x8bit if SPI definition is 8Bit? I assume (unfortunately) only 8x16Bit, right?
The second while is demanding more time and importance
"/* Wait until the Busy bit is cleared */
while ( !(SSP0SR & SSPSR_BSY) );"
Question3: If the SSP Interrupt is activated, all error related INTs enabled "SSP1IMSC = SSPIMSC_RORIM | SSPIMSC_RTIM;" (see all NXP examples) AND I make no dummy-read @ "SSP0DR" OR I comment this "SSPSR_BSY-while" I immediately
get a "hard fault". I set a breakpoint in my interrupt, but the hard fault occures before my breakpoint was reached (LPC-Link)
Do you have any idea why? I only expected an interrupt! (yes, in my interrupt I made a dummy read and cleard the int-flag) Ideas are welcome
Back to my first target... to increase the bit rate means, to reduce the "byte to byte time" = the gap between two 8Bit messages...
The time from start of byte1 to start of byte2 WITH the two "while" loops is 3,32µs.
If I made a comment for the first and second AND disable SSPIMSC_RORIM and SSPIMSC_RTIM I have 2,36µs and no hard fault any more. So the "/* Wait until the Busy bit is cleared */" takes app 1µs which is app 72clock cycles
So if I take care about FIFO-state and busy bits it should be possible to speed up, right?
(I only need MOSI=I am only transmitting!)
Volker