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.
    "We suspect that ALMA will allow us to observe this rare form of CO in many other discs.
    By doing that, we can more accurately measure their mass, and determine whether
    scientists have systematically been underestimating how much matter they contain."
  • Wow that works, neat.
Sign In or Register to comment.