Help debugging basic assembly code
SRLM
Posts: 5,045
Well, this is my first dive into PASM. I'm trying to modify the MCP3208 3 chip driver to automatically sample all channels (as opposed to sample on command). The original driver can be found here: http://obex.parallax.com/objects/403/
What I've done is take out everything in the spin sections except the start and stop methods. In the assembly, I've modified it to call the setup routine, then take readings in the average routine for all the channels, then write the results to the hub, then go back to the average routine.
Somewhere, the code has hung up. I haven't really figured out how to use the PASD debugger yet, but (assuming that I've got it correct so far) one problem might be in the very beginning. The PAR that is passed is supposed to be the pin definitions, but according to PASD (screenshot attached) the actual pin definitions are a couple dozen memory locations down.
The serial terminal output remains constant, although I have chip one hooked up on all eight channels:
Does anybody have an ideas on how to fix the code?
Post Edited (SRLM) : 8/11/2009 4:16:58 AM GMT
What I've done is take out everything in the spin sections except the start and stop methods. In the assembly, I've modified it to call the setup routine, then take readings in the average routine for all the channels, then write the results to the hub, then go back to the average routine.
Somewhere, the code has hung up. I haven't really figured out how to use the PASD debugger yet, but (assuming that I've got it correct so far) one problem might be in the very beginning. The PAR that is passed is supposed to be the pin definitions, but according to PASD (screenshot attached) the actual pin definitions are a couple dozen memory locations down.
The serial terminal output remains constant, although I have chip one hooked up on all eight channels:
ADC 24 Channel Test (chip numbers start at 1) Cycle: 23 Chip 1, Channel 0 : 25 Chip 1, Channel 1 : 25 Chip 1, Channel 2 : 0 Chip 1, Channel 3 : 0 Chip 1, Channel 4 : 0 [noparse][[/noparse] ... the rest of the values are 0 ]
Does anybody have an ideas on how to fix the code?
Post Edited (SRLM) : 8/11/2009 4:16:58 AM GMT
Comments
higher than the previous, so your start methode must pass the parameters like this:
But because you get the parameters in the right order, this is much simpler and does the same:
And in the assembly section you also need an offset of 4 for every long to read:
You also need to change the write_results with:
add count,#4
but I have not looked deeper in the assembly code yet.
After these changes you should see the right values at the right positions inside PASD.
Andy
Anyway, I did some more work on the program and it works now! At least, as far as I can tell. Thanks for your help.
Attached is a screenshot of how it looks on my Computer.
How do you pass the Source code?
In the PropTool, I select the Tab with the ..._test.spin file and press F10 to download, then I select the Tab with the ..._autoample.spin file and switch to PASD and press F2 (the first time, later I only minimize PASD while downloading).
Andy
However, I noticed that the first two labels were missing (entry and setup_). Screenshot attached, but the same source code as before. I got it to reproduce (both with minimization of PASD and redownload, and a clean start).
Also, I meant for the code that I posted to have the PASD stuff uncommented and the FullDuplexSerial stuff commented so that they don't interfere. I guess you did that, but just in case...
I got my code to work, but I thought I could make it go faster. This is what I came up with. Unfortunately, it doesn't work since I can't just add a mask to the wrlong. So, I'd have to have two separate add instructions (one for the hub pointer, one for the cog pointer), and the djnz instruction. So, that's three instructions that forces the wrlong to miss the window of opportunity, which in turn halves the data rate.
Does anybody have any solutions for how to write an array to the hub with a single wrlong and two more instructions?
I'm sure it must have been done somewhere...
1. create a variable containing the inc - both source and dest inc so you can add in 1 instruction
2. unroll the loop once - you have some spare cycles butnot enough, unroll the loop and you have 2x the spare cycles
3. also dont forget the pipeline you can put an add before the instruction you are adding and it will not take effect until net time round the loop