Spi Pru PDF
Spi Pru PDF
Spi Pru PDF
Page 1 of 5
You must set SPI up to run by using the previously described BB-SPIDEV9 overlay and
disabling HDMI. Again, P9.31 is SPI Clock, P9.30 is the stream being sent out (this
could also be P9.29 depending on settings). This is McSPI 1 channel 1 in the AM335X
manual.
This program will pass a word, number of words, and frequency to one of the PRU units.
The PRU will then repeatedly send the selected word out of the SPI channel for the
number of words at the specified frequency.
Note: The DTBO frequency is now superseded by the PRUs settings. It doesnt matter
what its set to in the BB-SPIDEV9 overlay.
Program Usage:
# ./SPI 808464432 1 0
INFO: Initializing.
INFO: Transmitting 808464432 (1 times) at 48000000 Hz
INFO: Sending...PRU program completed (4), in 0 seconds
This sends 0x30303030 down 1 time at 48 Hz. The resulting analyzer shot looks
something like this:
A B Interval: 20 ns
Doing multiples:
How far can we push it? Lets send 128 MB at 48 MHz and watch the CPU usage.
INFO: Initializing.
INFO: Transmitting 808464432 (33554432 times) at 48000000 Hz
INFO: Sending...PRU program completed (6), in 24 seconds
How about 24 MHz? This previously took about 60 seconds through the main processor.
Bulk DMA could also be set up to offload PRU usage as well. Currently, the PRU is
jamming 0x30303030 into the SPI FIFO repeatedly.
Relevant Registers:
CM_PER_SPI1_CLKCTRL @ 0x44E00050
Enable the Clock
MCSPI_SYSCONFIG @ 0x481A0110
Reset the SPI
MCSPI_SYSSTATUS @ 0x481a0114
Check Reset Completed
MCSPI_MODULCTRL @ 0x481A0128
Turn DMA off (for now)
MCSPI_SYSCONFIG @ 0x481A0110
Automatic OCP clock gating strategy is applied, based on the
OCP interface activity.
Nathan Barrett 9/30/14
Page 4 of 5
MCSPI_IRQSTATUS @ 0x481A0118
Disable Interrupts
MCSPI_CH1CTRL @ 0x481A0148
Turn on/off SPI CH1
MCSPI_CH1CTRL @ 0x481A0140
Set polarity, phases, frequencies, word length, tx/rx registers, etc
MCSPI_CH1STAT @ 0x481A0144
Check buffer empty/full
MCSPI_TX1 @ 0x481A014C
Load in data to transfer
MCSPI_XFERLEVEL @ 0x481A017C
Could set this up to take advantage of larger FIFO sizes. Currently not being used
Nathan Barrett 9/30/14
Page 5 of 5