Need Help With ADC Program
tom90
Posts: 55
I have been working on this program for a 12-bit ADC (max 1270) for a while, but I just cant get it to work.
When I started this I was new to assembler, but I think it is pretty close to working (Hopefully).
When I run the program the propeller doesn't output anything. I wasn't exactly sure how to set up the pin masks
at the beginning so that could easily be the problem.
Also, is my shift in routine correct?
My assembler knowledge has definitely hit a wall! If somebody could take a look at my code and point out some
errors, I would be greatful.
Thanks,
Tom
When I started this I was new to assembler, but I think it is pretty close to working (Hopefully).
When I run the program the propeller doesn't output anything. I wasn't exactly sure how to set up the pin masks
at the beginning so that could easily be the problem.
Also, is my shift in routine correct?
My assembler knowledge has definitely hit a wall! If somebody could take a look at my code and point out some
errors, I would be greatful.
Thanks,
Tom
Comments
I'm not sure what you are doing with all the mask stuff at the beginning. It seems to me you are overwriting your dira register several times. Maybe I misunderstand what you are doing there, but if you suspect your trouble is in the mask stuff at the front, why not simplify it?
As far as I can tell, by the time you get into BigLoop, you dira only has CsAdc. Yet in BigLoop it looks like you want to fiddle pins other than just pin 5.
Why not define DIRA all at once using something like:
DIRA_DEFN long %0000_0000_0000_0000_0000_0000_1010_1010
which would set pins 1,3,5,&7 as outputs. (provided that's what you want)
Then set dira in one command like this:
mov dira, DIRA_DEFN ' set DIRA
p
If I define the dira register like this then how do I define which pin is which in the program?
For example:
If I want to send my clock pin high I would say
mov outa, ClkAdc
How do I define which pin corresponds to "ClkAdc"
In the past i have simply used something like this to define "ClkAdc" as I/O pin 7:
However, people have told me to setup a pin mask like I tried in my program, but Im not sure if I did it right.
Thanks for the input
Tom
I usually set my pins up like this:
And access them like this:
Here's a snippet from a assembly routine I'm using to read an ADC
Hope that helps.
p
When you do this:
You are setting outa = ClkAdc which will set ONLY bit 7 of outa high AND CLEAR ALL OTHERS. If you only want to affect a single bit of outa, you'll need to use muxc.
p
Thanks a lot for the help!
I didnt know I was clearing the entire outa register when I was doing this.
I will give your advice a try tomorrow.
Thanks again
Tom
OR
and
ANDN
When you have the bits of the I/O pins in a 32-bit long X (a "mask) you do:
OR OUTA, X to set it, and
ANDN OUTA, X to clear it, and
XOR OUTA, X to toggle it.
When you use the first I/O ports n=0 ... 9 only you can use "immediate" addressing, but with hardly any advantage:
OR OUTA, #|<n
ANDN OUTA, #|<n
XOR OUTA, #|<n
You can of course also use "short masks" within the 9-bit range, i.e. when you want to use I/O 4 to 7.
You also best use CONSTANTS to improve readeability as well as simplify maintainance.
CON
io4to7 = $f0
DAT
OR OUTA, #io4to7
etc.