SimpleIDE SPI bus speed
Andrew Bubble
Posts: 21
HI Everyone, I need some help with the SPI bus speed using the Simple IDE, I recently posted a thread concerning the I2C bus speed and how to alter this.
I am developing an RGB LED controller using the Propeller chip. I am planning to use the Adafruit 24 Channel 12 bit PWM LED driver board. Link to the product below.
http://www.adafruit.com/products/1429
This uses a Texas Instruments TLC5947. I have looked round the net for information on the SPI bus speed but can't find any info. I plan to dedicate one of the cogs to the task of updating the lights when any of the data changes and I have to send 288 bits or 36 bytes to the TLC5947 chip.
Does any body know if there are a more suitable SPI library where I can set the desired bus speed, or can the one in the standard library be used in a different way.
Regards Andrew
I am developing an RGB LED controller using the Propeller chip. I am planning to use the Adafruit 24 Channel 12 bit PWM LED driver board. Link to the product below.
http://www.adafruit.com/products/1429
This uses a Texas Instruments TLC5947. I have looked round the net for information on the SPI bus speed but can't find any info. I plan to dedicate one of the cogs to the task of updating the lights when any of the data changes and I have to send 288 bits or 36 bytes to the TLC5947 chip.
Does any body know if there are a more suitable SPI library where I can set the desired bus speed, or can the one in the standard library be used in a different way.
Regards Andrew
Comments
Remember that the Propeller does all I/O in software with the exception of video where some things are done in hardware. With a clock speed of 80MHz, native instructions take 50ns. Depending on the memory model you're using, there can be a significant interpretive overhead. Even in-line assembly will only use native instructions if you've enabled caching (see the FAQ for the compiler for details).
I believe there's an SPI driver in the Propeller Object Exchange that can do 4MHz. I don't think it's designed to have a 50% duty cycle clock and it's written in native assembly code (and Spin) for use with Spin.
Thanks for the reply and info, and apologies for my ignorance but I assumed there might be a library somewhere similar to the I2C one I am currently using example below.
i2cOpen(&Dev, scl, sda, ClockSpeed). This has a clock speed parameter which I set to 400 KHz. I don't need a really fast speed and the 4MHz you stated above would be more than sufficient. Do you know what speed the SPI library routines in the Simple IDE run at, I can't find any info on this.
Also I am very new on the assembler of the Propeller but I am quite proficient using the C language, can you recommend some good reference material for writing assembly within the SimpleIDE.
Regards Andrew
Maybe someone else can chime in on ways to get up to speed using a mixture of C and assembly. Have you any experience with any assembly language or just C?
A few months ago I had a similar question and worked with Andy Lindsay to put together a SPI library for SimpleIDE C. The almost final result is post # 13 in this thread:
http://forums.parallax.com/showthread.php/157678-C-learning-SPI-example-with-MMA7455-only-gives-values-with-all-bits-set
Attached to that post is a zip folder that contains the library, the necessary files to include in a project, documentation for the library (in both an HTLM file and in the c and h files), and a couple of example files. The examples are for:
- DS1620 Digital Thermometer -- libspiasm.c (I need to change that name to something descriptive -- someday)
- MMA7455 3 axis accelerometer -- mma7455.c
The method works by using the assembly language routine in the file xSPIAsm.spin (originally SPIAsm.spin from the OBEX with a couple of mods to the assembly language file). xSPIAsm.spin has to be included in the SimpleIDE project list for your program.
To use this make a folder called MyLibrary under SimpleIDE/Learn/Simple Libraries/ and copy the unzipped folder into it.
The SPI library should work. My work remaining is to make some examples, make the file names descriptive, and finalize documentation.
As far as speed goes, the clock setting "clockd_ns" is limited to a minimum of about 300ns (From the spin PASM program, I haven't had a device that goes that fast so I can't test that. So I can't say that this will be as fast as you need.)
The methods used for developing the PASM library are discussed in this thread:
http://forums.parallax.com/showthread.php/157441-Can-SPI-in-Simple-Libraries-be-speeded-up
However, the library attached to post # 66 of that thread is an earlier version, so use the one in post 13 of the first thread. (I have to put the final version in that thread to close it out once its finished.)
Hope this helps
Tom
Regards Andrew
Tom's library is way faster than shift_out & shift_in, so thank you, Tom!