New P2 eval board, confused, need help
CRST1
Posts: 103
in Propeller 2
Got the new evaluation board. I have the P1 working with a couple frequency counters on inputs. I'm confused on how to do this on the P2. I guess it would use the smart pins in a certain mode.
It looks like the mode may be one of these:
%10101 = For periods in X+ clock cycles, count time
%10110 = For periods in X+ clock cycles, count states
%10111 = For periods in X+ clock cycles, count periods
This is very new to me and I have been reading and searching for some info but not much makes sense yet.
Could one of the more versed people get me started with some example on using the smart pin modes to get a frequency for a P2 beginner. Also not a P1 expert by all means either, so be gentle on me.
As far as I can read I have to set the smart pin mode and then read Z for the measurement.
I just need something to get me started understanding it.
Thanks very much
It looks like the mode may be one of these:
%10101 = For periods in X+ clock cycles, count time
%10110 = For periods in X+ clock cycles, count states
%10111 = For periods in X+ clock cycles, count periods
This is very new to me and I have been reading and searching for some info but not much makes sense yet.
Could one of the more versed people get me started with some example on using the smart pin modes to get a frequency for a P2 beginner. Also not a P1 expert by all means either, so be gentle on me.
As far as I can read I have to set the smart pin mode and then read Z for the measurement.
I just need something to get me started understanding it.
Thanks very much
Comments
We really need some easy way to operate something low-level, like this frequency counter arrangement, and then show the results on a screen, for easy viewing. I wish I had Spin2 done, but ersmith's compiler may have objects, already, for displaying data on video screens. I could write an example right now, but displaying the data would be the headache.
Maybe Jmg can show something. He's the driver behind this counter methodology being implemented. It's the best way to measure frequency accurately and quickly.
wrpin_(%0000_0000_000_0000000000000_00_10101_0, 20)
I'm not sure how to set the %P..P: low-level pin control
I'm confused on the table for this.
wxpin_ would be the # cycles to track for?
wypin_ would be %00 A-input rise to B-input rise?
And then read with
RQPIN D,S/# {WC} ?
I've been looking at this just now myself. And got a question I'm not sure is answered in the docs: Do interrupts get a double blocker there?
Yes, they do.
I find BASIC is a pretty good way to do simple prototyping. Here's a small program for testing out the smart pin. It uses the "increment on A-rise" smart pin mode to count transitions. I've got it set up to count on the serial rx pin, so you can type characters at it and watch it change based on what you type:
To run: save this in a file like "counter.bas". Open flexgui.exe. Use File > Open to select counter.bas. Click on "Compile & Run on P2". It'll open up a terminal window and print: Now if you type characters it'll print new "xval" values based on the number of low->high transitions in the character. There will always be at least 1 (for the stop bit).
Edit: deleted some unused variable declarations in the program, and reduced the pause to 100ms
I have pin 56 and 57 flashing and a jumper from one of them to pin 7
It just reads 0
I have pin 56 and 57 flashing and a jumper from one of them to pin 7
It still just reads 0
I loaded yours and it does work
Can you tell me what is wrong with the way I am doing it?
Also, you may want to use "rdpin" instead of "rqpin". It probably doesn't matter in the accumulate example, but I think reads from the smart pin should be acknowledged in order to reset the period. You can do this either with "akpin" (if you use "rqpin") or by using "rdpin" which does a combination of read and ack.
I have a jumper from pin 56 to pin 7.
pin 56 is flashing and hooked to pin 7 but still reads 0
Thank you. That was the problem. I thought I had tried that but guess I didn't.