ASM/ADC Question
tom90
Posts: 55
I have been writing code to control a max 1270 ADC.· Most of the code is in assembler but I pass
the final value back to a cog running spin to output the final ADC value.· This isn't fast enough!
Is there any way I can output my ADC value directly from assembler (without going through the hub)
to something like hyperterminal or vb?· (Something like the debug.dec statement only for assembler).
Or is there any other way of doing this that is much faster?
Thanks
Tom
Post Edited (tom90) : 1/31/2008 9:18:44 PM GMT
the final value back to a cog running spin to output the final ADC value.· This isn't fast enough!
Is there any way I can output my ADC value directly from assembler (without going through the hub)
to something like hyperterminal or vb?· (Something like the debug.dec statement only for assembler).
Or is there any other way of doing this that is much faster?
Thanks
Tom
Post Edited (tom90) : 1/31/2008 9:18:44 PM GMT
Comments
Hyperterminal or VB is already way slower than anything you'd write in Spin because of the serial communications.
Even at 115KBps, you're converting the ADC values to character strings, then adding additional text in the form of
"ADC Value: ", then blanks after the value ... all of which takes time to transmit. You need to go back to basics and
think about what you want to accomplish overall. For example, do you want to convert a series of values at maximum
speed, then display them? If so, what do you want to use as a trigger to start? Perhaps you need to buffer values?
Perhaps you need to buffer values and stop when a display trigger occurs, then display the last "n" values? If speed is
of the essence, you may want a parallel ADC rather than the multichannel serial ADC you're using.
I didn't have a chance to look in detail at your assembly code, but it seems like the timing may be too fast for the ADC.
At the 20MHz clock you're using, most instructions take 200ns which is a 5MHz rate. I don't know how you've hooked
the ADC up, but you need to take at least 3 instructions to do a clock to get a 2MHz rate. Make sure your timing is correct.
Two points that will speed you up a little.
Use the built in counters to feed the 1270 a clock and waitpeq and waitpne to sync with the clock and strobe line.
Leave cs low instead of switching.
As mike said though, serial out is a bottle neck, not the asm.
Also, look at the data sheet, it's possible to start output of the next control word before the last result is clocked in!
It is the intermediate handling through SPIN from the binary value to a converted string.
I did purposely not optimize this, to make the point more obvious: This loop delays your processing around 400µs/sample