Split personality IO pin

I've been using the smartpin repository mode in my Micropython experiments and I discovered I can use the same pin as an output too.

In this example a pin is toggled at a spped set by it's own repository value.
This feature frees up pins for more fun!
con
	vsync = 56

dat	org

	coginit	#16,#@speed

	wrpin	#%01_00001_0,#vsync	'long repository mode and OUT enabled
	dirh	#vsync			'enable smartpin

loop	rdpin	pb,#vsync		'get speed from smartpin repository
	getct	pa
	testb	pa,pb wc
	outc	#vsync
	jmp	#loop

	org
speed	waitx	##25_000_000 * 2
	wxpin	#23,#vsync			'slow speed
	waitx	##25_000_000 * 2
	wxpin	#20,#vsync			'faster speed
	jmp	#speed
Melbourne, Australia

Comments

  • I got proper confused once doing that because the pin's DIR is controlled with %TT config bits instead of with DIRx instruction.
    "... peers into the actual workings of a quantum jump for the first time. The results
    reveal a surprising finding that contradicts Danish physicist Niels Bohr's established view
    —the jumps are neither abrupt nor as random as previously thought."
  • Wow that works, neat.
Sign In or Register to comment.