Thursday, February 14, 2008

EVK1100: SPI @ 15 Mbaud.

It's good to see you after long time... especially with good news.

In the meantime I have been playing with EVK1100, an AVR32 development kit from Atmel. See for yourself at the Atmel EVK1100 website, the list of features is quite long... I have to admit, this is a truly wonderful beast with the exception that almost all the pins are in use.

My goal is to connect it to a Micron MTM9001, which is a 1280x1024 monochromatic CMOS image sensor and get at least 40 rows from it at 15 fps. In other words, I want to see these two mated:


The image sensor has parallel interface with the allowed clock range 1...50MHz, however, the microcontroller is a absent of fast parallel peripherials and I am not exactly fond of digging through a few hundred thousand interrupts each second. Fortunately, the small number of rows permits use of one of the many serial interfaces on board provided that the transfer rate is at least 12 Mbaud. This speed easily rules out traditional USART-s and I am left with either SPI or SSC (serial synchronous interface), of which I prefer SPI. Ethernet would be even faster, but let's not be overly clever. All of these built-in peripherials are connected to DMA and thus the CPU is free to save the world or perform SETI (whichever is required first) during video capture.

Thus, the first concern is whether SPI is able to perform at the required speed. Datasheet simply states that SPI can be clocked at speeds up to the PBA (Peripherial Bus). Given that my PBA clock is 30 MHz, it would be more than plenty. However, life has given me one or two lessons about the value of these pesky little facts in the datasheets and I have to admit I am not in a position to be teached one more time. Thus I set out to find if the SPI can be really used at the required speeds.

Speed test requires two SPI interfaces, in other words, both of EVK1100. These two are connected as follows:
* SPI0/slave - can be reached from the connector; it is not connected to any on-board peripherials. Let me note that the screen silk has MISO/SCK swapped, watch out.
* SPI1/master - connected to SD/MMC socket, LCD, on-board AT45 data flash.
Obviously the Peripherial DMA is required.

For the sending end I created 1024 elements buffer, filled with consequental numbers in the range 0...1023. This buffer is quite small and fits nicely into SRAM, thus ensuring maximum possible transfer speed.

The receiving buffer was placed in the SDRAM, since it consisted of 300 "frames", each of size 32000 elements.

I first tried at 1 000 000 Mbaud, since it seemed like a 'safe' speed. As predicted, everything worked seamlessly. Second try was at half the PBA clock, 15 000 000 Mbaud and again, success.

In order to cut this chain of successes, I tried at the maximum speed possible, 30 000 000 Mbaud and observered lightning fast transfer and indeed, the verifying step failed at the first byte.

Lessons learned:
* SPI operation in master and slave modes.
* Peripherial DMA.
* Last but not least, SPI is suitable for connecting image sensor.

The camera to SPI interface is now in the works. Since it takes some time, I have time to learn how to use the USB for communication with PC and why not use it to send some pretty images to the PC?

1 comment:

Mohammad Ullah said...

Hi,
I found a lot of valuable information from your site. I also think to work similar like that.
I want to use general web camera to capture the images through the USB communication port. I have evk1100 board as well.
Anyone have idea, is it possible to work like that.