View Full Version : I give up - Need Help

01-11-2008, 12:25 AM
Hello Forum

I need some help with the posted files. I try to explain my problem.·In the "Main",·I start a reading·of a·MCP3208 AD. "child" reads all 8 channels and store them. Then it should put the results back in a array in "main". The result of 5 channels is "transmitted" as it should. But 3 is not. And I can't figure out why. Just to test I write "123"·rather then·the·real value from AD.

I'am looking for speed in my application so if anyone find something that could be improved please let me know (probably a bunch of stuff http://forums.parallax.com/images/smilies/smilewinkgrin.gif .


01-11-2008, 01:01 AM
This is no good:

t4 res 1
adc word 8
command res 1 ' for 3208 routine

You wanted
adc RES 8
I presume?

01-11-2008, 03:04 AM
Thx deSilva for the quick respons

That solved the problem. Why did it work for the first·and 5-8th channel?

But my idea was to store the values in 8 words. And then "transfer" 4 longs·to save some instr (I know that I'm not "transfering" longs at the moment but I want to in the future). Does that make sense? Is it possible?

word 1-
word 2 - long 1

word 3 -
word 4 - long 2

word 5 -
word 6 - long 3

word 7 -
word 8 - long 4


01-11-2008, 05:35 AM
Well it's not clear to me what all your timing constraints are:

With words you can transfer 8 of them in:

WRWORD adc, dest
ADD dest, #2
WRWORD adc+1, dest
ADD dest, #2
WRWORD adc+2,dest
ADD dest, #2
WRWORD adc+3, dest
ADD dest, #2
WRWORD adc+4, dest
ADD dest, #2
WRWORD adc+5, dest
ADD dest, #2
WRWORD adc+6, dest
ADD dest, #2
WRWORD adc+7, dest

8*16 ticks =1.6 µs = 600 kHz

This delays the sampling.. I have not counted what the sampling part takes..
But there is little chance you can do ANYTHING at all in SPIN at this fast pace...

Post Edited (deSilva) : 1/11/2008 12:37:24 AM GMT

01-11-2008, 06:52 AM
Andreas, Here is some code for spi using two cogs. It no doubt "is not" what you need, but will give you a concept of how to get more speed from an spi. I actually used three cogs, one to write, one to read, and one to validate my readings and stop the recording when I found what I wanted in the circular buffer.

Again, it is not a general purpose spi, But maybe it will give you an idea or two!

01-11-2008, 08:17 AM

I see you modified my assembly code from the object exchange (MCP3208_fast).



01-12-2008, 12:48 AM
The program I posted is not all of it - it doesn't show what I really want to do. My goal is to fill a buffer (512 bytes) in child. And then in spin write that buffer to a SD-card. While the Main is writing the first buffer, child will fill a second buffer of 512 bytes. As you all have figured out I'am new to the propeller - but could this be a good way to do it? Or is there an better way to do that?

Maybe I'am wrong but I don't think the AD can handle more speed. But maybe I can use it for the SD-card to speed things up...

Yes, a big thanks - the object exchange is a life saver! Hopefully I can contribute in the future :)

Thanks to You all for your ideas and your time


01-12-2008, 12:56 AM
Andreas, you have to get a more precise feeling of where time is spent... There are huge diferences between SPIN and machine code; a factor of 2 or 3 can be gained or lost be different instruction scheduling.

But it needs that you exactly count and calculate the time needed for all steps...

01-12-2008, 01:24 AM

You said you think the A/D can handle more speed. The code that you're using (MCP3208_fast) has been tuned to sample the MCP3208 at the fastest speed allowed by the chip specifications.

You can increase the adc sample speed by over-clocking it. I've experimented with this and the chip seems to handle a faster speed without a problem. However, I didn't want to release something to the object exchange that operated outside of the chip specs.

Let me know if you need more help with this.


01-12-2008, 06:43 PM
Okej - I continue with the work and when I have a working program - I hopefully will be able to see where I have the bottlenecks.

Actually I didn't think the AD could handle more speed. And as for the code MCP3208_fast I didn't that could be improved either (take that as a compliment). But that sounds great - I never thought about overclocking the AD. But as for now I need to get the rest of the code working as I want. And later on I may hold you to your word :D.
How much did you overclock the AD?