Testing pins for shorts using Smartpins and pullups/pulldowns
Cluso99
Posts: 18,069
Changed the title to better reflect this thread
See a few posts down for working code
Latest code attached to this post. Compiles with flexspin.
@ManAtWork also posted some test code here
forums.parallax.com/discussion/comment/1510159/#Comment_1510159
I am trying to test out my boards and need to set pullups and pulldowns but it's not working because I don't understand exactly how to configure them.
I think the problem is that I am not initialising the smart pins correctly. Also, not sure the best way to read the pins either as I get different results with rdpin vs pinread.
This is what I have (using jonnymacs serial driver)
See a few posts down for working code
Latest code attached to this post. Compiles with flexspin.
@ManAtWork also posted some test code here
forums.parallax.com/discussion/comment/1510159/#Comment_1510159
I am trying to test out my boards and need to set pullups and pulldowns but it's not working because I don't understand exactly how to configure them.
I think the problem is that I am not initialising the smart pins correctly. Also, not sure the best way to read the pins either as I get different results with rdpin vs pinread.
This is what I have (using jonnymacs serial driver)
CON _clkfreq = 200_000_000 ' clock frequency _BAUD = 115_200 ' serial speed rx_pin = 63 'pin serial receiver tx_pin = 62 'pin serial transmitter LOPIN = 0 ' lowest io pin to be tested HIPIN = 15 '57 ' highest io pin to be tested OBJ term : "jm_fullduplexserial" ' serial terminal PUB main() term.start(rx_pin, tx_pin, %0000, _baud) ' start serial waitms(5000) ' 5s delay for PST term.fstr0(string("Testing io pins...\r\n")) setup_pins(LOPIN, HIPIN, P_HIGH_15K) ' set pins with 15K pullups setup_pins(LOPIN, HIPIN, P_LOW_15K) ' set pins with 15K pulldowns repeat ' <---- loop indefinitely PUB setup_pins(lowest, highest, mode) | pin, v, p repeat pin from lowest to highest ' pinstart(pin, mode, 0, 0) ' clear and setup pin(s) pinclear(pin) ' clear pin wrpin(pin, mode) ' set smart mode waitms(2) ' ?? just in case v := rdpin(pin) ' read back pin p := pinread(pin) ' read back pin term.fstr3(string("%2d %8x %8x\r\n"), pin, v, p)
zip
9K
Comments
If you also want to read back the ADC node voltage you can do this using TT bits and a couple of smartpin commands. I'll post a MicroPython demo in a moment that does this (its in MP but the constant names are same as Spin2)
So, you have to drive pin high for pull
up to work and drive pin low for pull down to work...
The apparent delay will partly be rise time. About 8 ticks is for I/O stages but the rest is a charge curve timer of the 15 kR vs the pin/board capacitance. If you use higher sysclock frequency then you'll also need a bigger WAITX.
Is it still 8 clocks turnaround at RCFast evanh? Wouldn't it be fewer?
Presuming spin translates to using waitx, at 200MHz it's 25*5ns = 125ns plus the spin decoding over head.
Cannot recall how many clocks it takes to clock out, then back in. but there is spin overhead here too.
Then I added to the program and just typed waitx(n) without thinking.
BTW love your term.fstrn with parameters for decimal, hex etc!
Might be worthwhile adding a sample pullup method to your jmtosp_demos.spin2 program
Here is the code And the program output And with forced errors (delay=30)
OT: Don't you just hate the way editing programs put in tabs even when you have spaces switched on! I'm using VSC with spaces: 2.
Love all these little snippets you do! Such a help for anyone trying something new.
You could also hook on an unconnected VGA cable, if its proper coax its going to load R/G/B around 35pF per foot