Building up your PASM test / debug environment.
potatohead
Posts: 10,261
So, what do you do?
I'm curious about the different approaches.
Mine is to knock up some code that outputs things I want to see. My preference on the Prop is to use a cog for video, then dump things to the screen.
Some handy goodies are, print hex, print decimal, print binary.
Also a memory scan is good, like writing a section of the HUB memory to the screen quickly. Can see stuff change.
A routine to pause until button pressed on pin.
Blink the light.
With video, it's all about the base signal, which requires a lot of thought, or time and a scope. Once that's done, then writing things inside the signal loop can be done with the other methods, or can be done in a way that leaves output to be seen.
So, how do you boot-strap your PASM working environment?
I'm curious about the different approaches.
Mine is to knock up some code that outputs things I want to see. My preference on the Prop is to use a cog for video, then dump things to the screen.
Some handy goodies are, print hex, print decimal, print binary.
Also a memory scan is good, like writing a section of the HUB memory to the screen quickly. Can see stuff change.
A routine to pause until button pressed on pin.
Blink the light.
With video, it's all about the base signal, which requires a lot of thought, or time and a scope. Once that's done, then writing things inside the signal loop can be done with the other methods, or can be done in a way that leaves output to be seen.
So, how do you boot-strap your PASM working environment?
Comments
-Phil
LOL.. ROFL:rofl:
I'm working on some IR stuff. Initially I created a 38 kHz carrier on one cog and can test that with the Basic Stamp or frequency counter.
Then I send data with PASM switching on/off the 38 kHz on another cog and output via an IR transmitter LED.
Then use yet another cog to read the data with an IR receiver, then that sends the test data to serial terminal.
So on my breadboard I have an IR transmitter pointing at an IR receiver and both connected to the same Propeller.
Other times I use a regular LED or multiple LED's to test a certain part of a program. I can then see what is happening.
Or if I want to know the value of a variable (troubleshooting), I'll output that to serial terminal.
And I have a multimeter handy for testing this and that. And a scope.
Also leds make good indicators.
And of course an oscilloscope is always
a useful tool.
I suppose ViewPort would be useful
but I have not worked with it much.
I do wish I had a copy though, it
would be nice to detail its usage
on my PASM blog. Maybe I will get
a copy of it in its most basic Lite form.
I once found a thread where Phil complained about not having a debugger
-Col. Philip C. Pilgrim, Esq., D.D., 3rd Propellah Regiment
Interesting! I've not run into that situation yet.
Bill
-Phil
I'm fortunate to have a Tektronix MSO scope, and have to 16 logic channels connected to output port bits 15..0. The 4 analog channels mostly get used for other signals. So far all my work is in assembler (don't understand SPIN yet), so when testing my code, I usually want to know the value of variables at various points, and so I simply insert the following snippet at those places:
mov Hold,outa 'keep the present port value
mov outa,VarableName 'show the lower 16 bits of the variable
mov outa,Hold 'restore the original port state
and carry on. It does require of course that those port bits be in the output direction at the time of the peek, and if they are not, then the DIRA also needs to be saved, altered and restored.
Works great, because it is all in real time.
Cheers,
Peter (pjv)
I pretty much do the same, but I use a 'special' LED that has the series resistor (330 ohm) built in so they can be quickly deployed without having also handle a resistor.
FWIW, Here are the Mouser p/n's
for the Green LED
SSL-LX5093GD-12V
and for the Red LED
SSL-LX5093ID-5V
the green has a bit larger series resistor and they are each nominally rated at 5V and 12V ... BUT they work fine at 3.3v Propeller voltages.
CAVEAT ... I find myself unable to visually distinguish one of these LEDs from its non-resistored brethren, I often suggest to people that if they will be mixed to dab a little Wite-Out on the base
One more comment, I have adopted a convention in both my personal work and all the kits I sell, that Green LEDs are for power (yellow for raw Vin) and Red LEDs for digital indicators.
cheers ... BBR
Other than that, i use a 4" or 7" widescreen lcd's for automotive headrests i got on the cheap and spit out variable data with TV Terminal object , or use PST.
For the most part I start out debugging with what seems to be the most practical for the task, starting out low level and working my way up the chain as the project matures.
LED - visual debugging
Speaker - audio debugging
scope - debugging for what we can't see or hear
Serial - debugging for when the bits have something to say
TV - when you just want to bring it all together
Edit: hey I'm HEX inverted (this was my 4049th) post
Anything more complex where I need to see the results I send characters or strings out the serial port to the pc.
I rarely use a scope - it mostly sits in its original carton. Unless of course I am doing something analog, which I suspect is where Phil is coming from.
I did have to write a debugger for the Interpreter to see that everything was OK and I did write a datalogger to check the pins and send to the pc.
As Phil said, you should test your code in pieces.
Quote from somewhere old... "The person who never had a bug in their code has never written anything."
Beau: 4049 hex inverter - isn't that a backwards step - you already achieved a 4004 microprocessor (well, it was just a smart programmable calculator). You can of course look forward to the 6502 or 6800. LOL
When you say "I print data to the screen mostly" are you referring to the PC monitor using the Parallax Serial Terminal?
Do you have any sample code you could share?
I am wondering how to display variables from within PASM code (other than writing values back to main memory where another cog could display it)
Thanks,
Ron
In desperation when I started out I had 8 LEDS on my Prop and would dump variables byte at a time to those with a little delay between each byte so you have time to read it. Not recommended.
Also I have used just one LED to light up if a PASM variable achieves a value I think it should have. Also not recommended.
By far the simplest is dumping values to some high location in HUB, far away from your code, and have another Spin object dump it to TV/VGA or serial. Perhaps that is added to some existing process that is looping continually.
Where is this code of which you speak?
You can write stuff right to the screen.
Eric Ball has a hex font in his one pin TV driver. This can be used to directly read the memory. Recommended.
Just either write to where the screen is, or point the screen memory to a region of the HUB you want to view.