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.
    We have the vastness of the internet and yet billions of people decided to spend most of their time within a horribly designed, fake-news emporium of a website that sucks every possible piece of personal information out of you so it can sell it to others. And they see nothing wrong with that.
  • Wow that works, neat.
Sign In or Register to comment.