Using Procyon AVRLib in the Arduino IDE

Hello there, I would like to add the Procyoon AVRLib to my IDE. I tried putting the whole thing in lib/targets/ardunio, I tried in the libraries and I tried just putting the files I wanted in my sketch's directory. But to no avail. I'm sure it's something stupid I'm missing. Any pointers?

It should be possible in any of those ways, I think. What happens when you try it?

So I've gotten all the net stuff (and what it relies on) to compile using the "in sketch" method. However only using the Makefile. The IDE seems to try to compile the .cpp's as C instead of c++ (at least it's pretty much the same error I get when I replicate this in the Makefile). Still, it's not perfect, serial seems to be broken, doesn't send/receive anything. Even though I took care of removing all the uart stuff and replacing it by the Serial object). The timer classes are probably going to be an issue. So right now the biggest problem is avoiding wiring and avrlib to conflict; and I only have a small part of avrlib. Any pointers there?

What errors do you get when you try to compile things in the IDE? Or are you happy using the Makefile?

When you say that serial's broken, what code are you running?

The Makefile is fine for now, that's what I use normally. Right now I only wished I knew why the program makes the µC crash. As for serial I'm using Wiring's library.

EDIT: Here's the code.
As you can see in the setup there are a few Serial sends which never appears (sometimes just a few char return). Also atm the LED never ends up flashing. Like if the setup failed or the uC crashed when setting up Serial

Also, didn't anyone work on an ENC28J60 drivers for the Arduino? If so, is it available anywhere? Maybe it could help?

My first guess is that you're running out of RAM because of all the strings you've got in the code. Can you try commenting out everything but setup() and loop() and trying it again?

Well that helped a lot! I moved all of the strings to inline progmem with PSTR. Very neat, albeit it seems a little unreliable... stuff like this happen:

printString(PSTR("Uptime: ")); delay(2);
Serial.print(millis()); delay(2);
printString(PSTR("ms")); delay(2);

Show as :

 : 1848ask :

and some just don't print.

printString looks like such

void printString(const char *data)
{
    char ch;

    for (;;) {
        ch = pgm_read_byte( data++ );
        if ( !ch ) return;
            Serial.print(ch);
    }
}

I've tried delaying by 8xNOPs (1/2µS) to no avail.

But hey, at least there is progress hehe :slight_smile:

Weird. Does the serial communication work reliably with the same hardware but different sketches?

As far as I can tell, yes it is. There's some really... really... weird stuff. In my regDump function, none of the douzen serial strings are sent... I'll dig deeper I guess :confused:

GOT IT! I had two functions, one for print and one for println... well the first, called printString, was conflicting with wiring's printString. GCC never complained because wiring.h was not included in the files with the strings functions! FEW :o

Totally out of subject, but is there a way to know the ram specs? Such as how much is free, etc. The mega168 doesn't have JTAG (not that I have the cable), debugWire seems quiet complicated (no 2$ parallel hack) and simulavr doesn't support the mega168 as far as I could see and test. The only option I can see is AVRStudio. But running VMWare all the time seems like a bad idea, not to mention having to replicate the environment under two totally different platforms. And I've seen reviews saying it didn't run under Wine. What does that leave us with for debugging? :confused:

I'm not sure. I think someone posted a sketch with a function that would calculate how much RAM you had free (by trying to allocate more and more memory until it failed, I think). If you find a good approach, that would be awesome.

That's exactly the approach I was going to take. It would be sufficient for basic debugging at least.

I wrote this but it didn't seem to work:

char b[2048] = "a";
unsigned int i = 0;
Serial.println();
for (i = 1; 1; i++) {
      Serial.print(i); Serial.print(" "); delay(100);
      b[i] = 255; 
}

I looked a little for the sketch and didn't find anything, was it posted on the forum?