chipKIT® Development Platform

Inspired by Arduino™

error on library

Created Thu, 23 Jul 2015 08:29:26 +0000 by albatrillo


Thu, 23 Jul 2015 08:29:26 +0000


I'm trying to create a program that has a signal output PPM (pulse-position modulation) with 8 or 9 channels. There are very good lirerias for Arduino, Arduino operate well, but I get compile the "PPMout_example" under board Mpide chipKIT program. My programming level is not high, but I have to work.I leave here the link below, to see if someone can help me.

this is the error:

[color=#FF0000]\Microchip ChipKit\mpide-0023-windows-20140821.\hardware\pic32\libraries\RC\Curve.cpp:14:0:

mpide-0023-windows-20140821\hardware\pic32\cores\pic32/avr/pgmspace.h:4:2: error: #error ******** This sketch or library uses AVR-specific code that may not work with the chipKIT platform. See this forum for more information on porting code to chipKIT [] ******** Microchip ChipKit\mpide-0023-windows-20140821.\hardware\pic32\libraries\RC\Curve.cpp:25:30: error: expected initializer before 'sc_defaults' Microchip ChipKit\mpide-0023-windows-20140821.\hardware\pic32\libraries\RC\Curve.cpp:110:1: error: expected '}' at end of input[/color]

This libraries work perfectly under Arduino sofware.

Help me please!

Thank you very much!!


Thu, 23 Jul 2015 12:37:25 +0000

The library you are using (RC, whatever that is) is written in such a way that it won't work on anything except an AVR board.

To use it on chipKIT (and indeed anything else that's not an Arduino) you will need to "port" that library to the new hardware.

More details can be read here:


Thu, 23 Jul 2015 13:20:00 +0000

apparently it is a conflict of architecture.

I appreciate the help but my programming level and my English is not high enough to fix the problem :oops: . if anyone can fix it, I would do a good help because I can then compare and see change as has been fixed for future arrangements. ;)


Thu, 23 Jul 2015 19:20:51 +0000


You want to switch over to using the SoftPWMServo library. It comes with MPIDE. Look at the examples that come with the library for ideas on how to use multiple RC servo outputs at the same time. Let us know here if you're having specific problems with parts of your code and we'll do our best to help you out.



Thu, 23 Jul 2015 19:39:05 +0000

the code is:

this code work on arduino but don't work on mpide. I think the problem is the system timer arduino work 16mhz but MAX32 work 80mhz, is more fast

I think the problem is in this part

cli(); TCCR1A = 0; // pone todo el registro de TCCR1 a 0 TCCR1B = 0;

OCR1A = 100; // compare match register, change this TCCR1B |= (1 << WGM12); // pone ON el modo CTC TCCR1B |= (1 << CS11); // 8 prescaler: 0,5 microseconds at 16mhz TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt sei();

and this sketch...

I think I need to change this:

// Setup timer for arduino TCCR1A = B00110001; // Compare register B used in mode '3' TCCR1B = B00010010; // WGM13 and CS11 set to 1 TCCR1C = B00000000; // All set to 0 TIMSK1 = B00000010; // Interrupt on compare B TIFR1 = B00000010; // Interrupt on compare B OCR1A = 22000; // 22mS PPM output refresh OCR1B = 1000;


Gary Freegard

Fri, 24 Jul 2015 12:26:28 +0000


Yes, you are right the problem is setting up the timer and it's interrupt. Use the code below, its sets up timer2 with interrupt. I have assumed that the timer clock is at 80MHz, could be at 40Mhz. If output is at 44ms then change T2_PS_1_32 to T2_PS_1_16.

unsigned int timeout = 55000; //this should give you 22ms fingers crossed

void __attribute__((interrupt)) T2()
	  mT2ClearIntFlag(); // Clear interrupt flag

void setup()
	setIntVector(_TIMER_2_VECTOR,T2); // sets interrupt to use
	OpenTimer2( T2_ON | T2_PS_1_32 | T2_SOURCE_INT,timeout);// Turns timer on, prescaler set to 32, source is internal
	ConfigIntTimer2((T2_INT_ON | T2_INT_PRIOR_3));// turns interrupt on and sets priority

You may need to change/adjust the timeout value as I just calculated it and maybe the prescaler.

Good luck