Go Down

Topic: Using Procyon AVRLib in the Arduino IDE (Read 4285 times) previous topic - next topic


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?


Sep 11, 2007, 10:04 pm Last Edit: Sep 11, 2007, 10:05 pm by xSmurf Reason: 1
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?


Sep 12, 2007, 02:15 am Last Edit: Sep 12, 2007, 02:56 am by xSmurf Reason: 1
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:

Code: [Select]

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

Show as :
Code: [Select]

: 1848ask :

and some just don't print.

printString looks like such
Code: [Select]

void printString(const char *data)
   char ch;

   for (;;) {
       ch = pgm_read_byte( data++ );
       if ( !ch ) return;

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

But hey, at least there is progress hehe :)


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 :/


Sep 12, 2007, 11:59 pm Last Edit: Sep 13, 2007, 12:04 am by xSmurf Reason: 1
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? :/


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.


Sep 13, 2007, 01:46 am Last Edit: Sep 13, 2007, 01:46 am by xSmurf Reason: 1
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:
Code: [Select]

char b[2048] = "a";
unsigned int i = 0;
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?

Go Up