chipKIT® Development Platform

Inspired by Arduino™

avr/io.h compatibility question.

Created Fri, 27 May 2011 00:41:36 +0000 by mself27


mself27

Fri, 27 May 2011 00:41:36 +0000

Just fired up my first Uno32 and it's FAAAAAAAAAAST. Lovin' it!!!

I've been playing with some LED strings using the HL1606 chips and the Uno32 is great for these because of the speed improvements over an Arduino Uno or Mega2560.

I'm having an issue, though, where the compiler is telling me that: avr/io.h:428:6: warning: #warning "device type not defined"

In examining the .h file, it goes through all of the different AVR chips and sets the model to the appropriate one so that later on, clocks, registers and other reserved memory locations can be set properly.

Question: Is the PIC32 compatible enough so that I can simply modify avr/io.h and tell it that it's one of the AVR models?

IOW, can I fake the IDE into using a set of already defined memloc values so that the following can get #defined properly: TIMSK2 OCIE2A TCCR2A WGM21 TCCR2B CS21 CS22 OCR2A TCNT2

Thanks & cheers, MIke.


Mark

Sat, 28 May 2011 14:55:47 +0000

can I fake the IDE into using a set of already defined memloc values so that the following can get #defined properly:

No, you cannot, even if you could find these memory locations, the bits that you put in them are TOTALLY different. There is no way you can even expect 2 manufacturers to have the same control bits. The timers even work differently.

At the abstraction layer, everything is the same, at least we hope so. At the low level you will have to re-write it.

You should NEVER include anything from the avr libraries i.e. #include <avr/io.h> for any project that does not use an AVR chip

from now on, you should be doing this. You will be seeing this type of code in the libraries that we work on.

#ifdef defined(AVR) #include <avr/io.h> #endif

#if defined(PIC32MX) #include <something> #endif


mself27

Wed, 01 Jun 2011 20:06:17 +0000

Thanks, Mark.


Jacob Christ

Tue, 07 Jun 2011 20:58:11 +0000

I've seen some lib's that looks like this:

#if defined(AVR_ATmega1280) || (AVR_ATmega2560) #endif

#if defined(AVR_ATmega168) || defined(AVR_ATmega328P) #endif

Are there defines for Uno32 and Max32 such as:

PIC32MX_Uno32 PIC32MX_Max32

Jacob


jasonk

Tue, 07 Jun 2011 22:10:29 +0000

There's a few predefined macros that you may find useful:

#define __PIC32MX__ 1
 /* For Uno32 */
#define __32MX320F128H__ 1 
/* For Max32 */
#define __32MX795F512L__ 1

andrewh

Tue, 03 Jul 2012 06:46:29 +0000

I've just received my new Arduino UNO and some HL1606 based RGB strip.

The strip is cabled in the following way:

SI -> pin 12 DI -> pin 11 CI -> pin 13 LI -> pin 10

With the Adafruit/HL1606-LED-Strip library installed, the example code works but the green and blue colours are inverted.

I fixed it by editing the HL1606strip.cpp file at the following section:

void HL1606strip::setLEDcolor(uint8_t n, uint8_t color) { uint8_t x;

x = 0x80; // latch

if (n > _numLEDs) return;

if (color & BLUE) x |= 0x10; The original value was 0x01 if (color & RED) x |= 0x04; if (color & GREEN) x |= 0x01; The original value was 0x10

_leds[n] = x; }

Saved and recompiled. Works fine!

Just wondering if this is the proper way to proceed.

./Steph