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!
	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

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


  • I got proper confused once doing that because the pin's DIR is controlled with %TT config bits instead of with DIRx instruction.
    "Those who think we are powerless to do anything about the greenhouse effect forget about the 'White House effect,'" - George H.W. Bush, 1988.
  • Wow that works, neat.
Sign In or Register to comment.