How to coordinate with Smartpin in NCO mode? IN not working?
Rayman
Posts: 14,557
I have pin#1 toggling using Smartpin in NCO mode like this:
Then, I'm trying to make pin#0 follow the output using testp on the smartpin like this:
Doesn't work though, seems in on smartpin is always high...
What am I doing wrong?
'Turn on pixel clock mov x,##SmartMode wrpin x,#PClkPin mov x,##$0D '1.2 MHz with $0D, 9.62 MHz with wypin=$8000_0000 wxpin x,#PClkPin mov x,##$1000_0000'8000_0000 'Toggle every n base period wypin x,#PClkPin dirh #PClkPin
Then, I'm trying to make pin#0 follow the output using testp on the smartpin like this:
TestLoop nop nop testp #PClkPin wc if_nc drvh #DePin if_c drvl #DePin nop nop jmp #TestLoop
Doesn't work though, seems in on smartpin is always high...
What am I doing wrong?
Comments
Also, unrelated to your problem, you can replace this: with this:
EDIT: ACKPIN -> AKPIN
This now produces a pulse on DePin every time PClkPin goes low:
This works fine at 1 MHz, but at 10 MHz only catches every 5th pulse:
You can use the smart pin input selector to read the output state of neighbor pins.
From the smart pin docs: Here's an example of reading a smart pins output state.
I am looking at the smart pin codes. I noted that you wrote:
wrpin #%1_00110_0,#56 'nco frequency mode
wxpin ##10000,#56 'base period
wypin ##$80000000,#56
This is in the docs:
D/# = %AAAA_BBBB_FFF_PPPPPPPPPPPPP_TT_MMMMM_0
I have seen in the forums what you wrote as well as something like this:
prng = %0000_0000_000_10100_00000000_01_00001_0
dither = %0000_0000_000_10100_00000000_01_00010_0 ' remember to wypin
dither_pwm = %0000_0000_000_10100_00000000_01_00011_0 ' remember to wypin
dac = %0000_0000_000_10100_00000000_00_00000_0
What is the easiest way or what of the aaaa,bbbb,fff,pppp etc can I leave out?
Thanks
The T field is often needed to force the pin's DIR high when using a smartpin. This is because the cog's DIR is now controlling the smartpin instead of the pin directly.
The P field is the most complex, it defines the pin config of the custom pins. All the interface attributes like pull-up resistors and switching on the ADC.
Fields A, B and F work together in selecting digital input sources. Input selector A works for cogs as well but only smartpins can see B. F applies to both A and B.
For clarity all the bit fields were shown.
You can remove all the leading zeros.
@ozpropdev
Thank you. I will experiment with the information.
I will let you know.
And to go with it, the P field write up is here - https://forums.parallax.com/discussion/comment/1452036/#Comment_1452036
EDIT: Added DAC paths to block diagram
EDIT2: Now shows DAC and ADC and comparator locations
EDIT3: Named a separate SMART_OUT after finding that OUT can be looped back as an input while the smartpin is the output without being circular
EDIT4: Typo correction: Was two "odds"
EDIT5: Rearrange "Other"
EDIT6: Updated with corrections after Chip provided more details - https://forums.parallax.com/discussion/comment/1494131/#Comment_1494131
EDIT7: Added X, Y and Z registers to smartpin
EDIT8: Added DAC Enable and smartpin ACK
EDIT9: Updated to latest - https://forums.parallax.com/discussion/comment/1495133/#Comment_1495133
Thanks
That made my day! You helped me a lot.
Kind regards, Samuel Lourenço
True, the prop2 can't be called minimalistic quite like the prop1 was. And the hardware config bits has grown numerous. But the symmetries that the prop1 had are still there, even in the new hardware, leading to plenty of mix and match possibilities.
It would be great if the two blocks could be published as PDF's, they are hard to follow with having to scroll.
To be serious, I have no skills at page layout so anyone is likely better than me at it. The reason I used text was because I was getting frustrated with other drawing software.
Sometimes it's nice to have a printer that can do 11x17 prints. Here are both sections as jpeg's in case that helps.
I love 11x17. I sometimes print Chips assembly instructions on 24x30. Thanks for that.
It is quick and dirty code, but may still be useful.
If errors are found, please report. I only tested it with a few examples.
I built it on Linux, but the cpp should also compile on other platforms.
(1): Those bits are for optional digital output drive. Maybe you want to apply a current bias to the ADC frontend.
(2): No for pin config to take effect. Yes, a high DIR is needed for smartpin to run (A low on DIR holds the smartpin in reset). If you just wanted the raw ADC bitstream appearing on IN, then leave the smartpin mode off (M=0) and DIR should stay low unless you want the output driven. Mostly you'll be wanting the smartpin to consume the bitstream though.
Additionally, a DIRL/DIRH pair are usually placed around any smartpin initialising code to neuter potential strange behaviour on initial mode change. Although, I have used a non-typical order to ensure the output stays driven when engaging a smartpin, but still providing the smartpin resetting function.
(3) and (5): No, SETSE1/2/3 are only if you want to make use of the hardware event system.
(4): Yep, RDPIN is how to read data for all smartpins. That's where the ADC's smartpin samples appear.
(6): Nothing extra for ADC function. With the Prop2, all the sigma-delta hardware is built in. The input voltage range is limited to -0.3 to 3.6 Volts though.
Thanks for the link and the information it contains.
I've tried a lot, but the result is always similar:
It doesn't matter whether I leave the pin open, connect it to GND or to VIO.
my current attempt:
I use about 20cm long laboratory cables to connect the pin to VIO / GND. Can it be that the converter is so sensitive and that the line induces something?
Another problem is %TT should be %00, %01 means the output is driven low to GIO voltage. This is reflected in the ADC readings when pin input is selected. Also, I'm guessing you didn't want x3.16 gain setting in the P bits. I'm thinking you were aiming for VIO selected instead. ie:
Please be patient with me. I used the above settings and set the sample period to 8 / 10 / 6.
I switched a potentiometer between VIO and GND. The middle tap goes to P0. With a voltmeter at P0, I set a voltage of almost 0 to 1500 mV.
Nothing changes in the result, a value (432) is constantly output via printf.
What else can I do wrong?
Andy
It works great!
I tried it out right now, then I look into the sources to learn how to do it.
Thanks for this example, Andy!
Reinhard
I have the config function
_dirl / _wypin / _pinl
not used.
And probably the biggest mistake:
I have not specified GND-ref and VCC-ref.
I have learned more from your example than from blind testing in the last 2 days.
Reinhard