chipKIT® Development Platform

Inspired by Arduino™

8x8x8 led arduino UNO to UNO32 code conversion

Created Sat, 22 Feb 2014 04:31:44 +0000 by goroth


goroth

Sat, 22 Feb 2014 04:31:44 +0000

I have created a 8x8x8 led cube and used the arduino uno for the controller. I would like to replace the arduino uno with a PIC UNO32. Currently I am stuck trying to understand the timer / CTC / interrupt code. The current code in arduino used register calls. I know the arduino runs at 16 Mhz and the UNO 32 is 80 Mhz. So I'm pretty sure I have to add more interrupt to slow the clock down to the code speed in the arduino. I found this link about the PIC timers but I still don't understand enough to actually convert the code. [url]http://www.johnloomis.org/microchip/pic32/timer/timer.html[/url] Any help with the conversion or any good links on understanding the CTC mode setup for the UNO32 would be great.

// Reset any PWM configuration that the arduino may have set up automagically!
	TCCR2A = 0x00;
	TCCR2B = 0x00;

	TCCR2A |= (0x01 << WGM21); // CTC mode. clear counter on TCNT2 == OCR2A
	OCR2A = 10; // Interrupt every 25600th cpu cycle (256*100)
	TCNT2 = 0x00; // start counting at 0
	TCCR2B |= (0x01 << CS22) | (0x01 << CS21); // Start the clock with a 256 prescaler

	TIMSK2 |= (0x01 << OCIE2A);

Jacob Christ

Sat, 22 Feb 2014 07:06:14 +0000

Timers are great, but with the extra power.of the Uno32 you might just consider using the mills () or the chipKIT task manager.

http://chipkit.net/started/learn-basics/chipkit-compatible-libraries/

Jacob