chipKIT® Development Platform

Inspired by Arduino™

mpide unable to locate avr/io.h?

Created Fri, 22 Jul 2011 03:54:07 +0000 by red24dog


Fri, 22 Jul 2011 03:54:07 +0000

Error message: C:\Users\xxxx\Documents\Arduino\libraries\PS2X_lib/PS2X_lib.h:82:20: fatal error: avr/io.h: No such file or directory compilation terminated.

Sketch had "#include <PS2X_lib.h>" contributed library, (that installed in the My Documents\Arduino\libraries folder.

The MPIDE sees the list of "Contributed Libraries" so that part seems OK. But avr/io.h called by the PS2X_lib.h library by "#include <avr/io.h>" which I found under the "mpide-0022-chipkit-win...\hardware\tools\include\avr\ directory but the compiler can't find it. This sketch compiles with the original Arduino Uno IDE. Should I be using a different Include in the PS2X_Lib.h with the chipKit Uno32?



Fri, 22 Jul 2011 10:42:06 +0000

It sounds like the PS2X_lib hasn't been ported to the ChipKIT. Because it uses low-level access to the AVR hardware, it will need some modification to the code. Unfortunately although the ChipKIT is compatible with Arduino sketches it is not compatible with most contributed libraries straight away because of the architecture differences.

It looks like the abstraction layer has not been used for some of the time critical parts of this library. It's going to take a while to sort it out and make it ChipKIT compatible, I can't see an equivalent io.h for it, I'd love to have a go but I really don't have time for the next month or two.


Fri, 22 Jul 2011 14:23:52 +0000

In taking a quick glance, it looks to be the same problem as the onewire library I modified. At the low level access they use eight bit pointers to memory location (uint8_t) but the Chipkit uses 32 bit pointers (__uint32_t). This is used for the set(), clr(), chk(), and tog() functions defined in the header file. Some of the commands can actually be enhanced by using the enhanced registers of the PIC32 (ie. PORTXSET or LATXSET). If you have a look at my modified onewire library you'll see that they are constant offsets from the TRIS register.

It shouldn't be hard fix, just use some ifdefs for AVR specific includes (ie. <avr/io.h>) and more ifdefs for the declaration of the pins (ie. _cmd_oreg) in the header file. There may be a little more work that I'm missing, but I also don't have the time right now to play with it.

Good luck.


Sat, 23 Jul 2011 03:18:41 +0000

Okay, I found some time to play with it tonight and have it compiling. I don't have a PS controller to try it out with so you'll have to let me know if it works for you.


edit: You will need a pullup resistor on your dat line.