Show Posts
Pages: 1 [2] 3 4 ... 11
16  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 11:14:30 am
Once again, thank you pYro_65. You're so helpful. smiley-grin I gave it a cursory read and it looks like that's the ticket. I'll spend some more time going over the details before I give it a try. From what I've read so far I'm guessing the .init3 section is where I need to place my ISR's. Is that correct? I know I need to RTFM. But just so I can browse a little before hand, where can I find the .text and .init sections. I'd like to see if I'm getting in over my head or not. I'm usually up for a good challenge. smiley-wink

DJ
17  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 09:51:02 am
@PaulS

Thank you for the what and why of this error message. This answered my questions from the OP of this thread. I know I should have posted code with my questions and I was going to shortly after I posted. But when I anylized the error message some more it led me to check the progmem area and what was in it. That led me to the cause. I do thank you for the explaination. I always like to know what exactly an error message means and possible causes. Even if some of the possible causes don't apply to my particular case, it's good to be aware for future reference and avoidance.

I'm going to look into pYro_65's suggestion of assigning the data ISR's to an area of memory. I need to get my atmel studio working with arduino sketches again to accomplish that. Which is what I'm going to do try to figure out next. BTW is it possible to assign data to an area of memory as pYro_65 suggested in the arduino IDE?

Thanks for your time guys. This forum is always helpful.
DigitalJohnson
 
18  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 01:35:40 am
There's 4 external interrupts (INT0, INT1, INT4, INT5 used for trackball directions) and 1 pin change interrupt PCINT0 with two pins being used (1 for a button under the trackball and 1 for an RTC irq). Trackball.xxxxx is a struct to hold relavant info. UP, DOWN etc. are const uint8_t's assigned to bit values.
Code:
void isrUp(void)
{
    static uint8_t upDir = 0;
    upDir++;
    if (4 < upDir)
    {
        upDir = 0;
        Trackball.directFlags = UP;
        Trackball.dataAvailable = true;
    }
}

void isrDown(void)
{
    static uint8_t downDir = 0;
    downDir++;
    if (4 < downDir)
    {
        downDir = 0;
        Trackball.directFlags = DOWN;
        Trackball.dataAvailable = true;
    }
}

void isrLeft(void)
{
    static uint8_t leftDir = 0;
    leftDir++;
    if (4 < leftDir)
    {
        leftDir = 0;
        Trackball.directFlags = LEFT;
        Trackball.dataAvailable = true;
    }
}

void isrRight(void)
{
    static uint8_t rightDir = 0;
    rightDir++;
    if (4 < rightDir)
    {
        rightDir = 0;
        Trackball.directFlags = RIGHT;
        Trackball.dataAvailable = true;
    }
}

ISR(PCINT0_vect)
{
    static uint8_t prevState = 0x03;
    uint8_t currentState = (0x03 & PINB);
    if ((0x02 == (0x02 & prevState)) && ((0x02 & prevState) != (0x02 & currentState)))
    {
        NONATOMIC_BLOCK(NONATOMIC_RESTORESTATE)
        {
            DS1307.update();
        }
    }
    if ((0x01 == (0x01 & prevState)) && ((0x01 & prevState) != (0x01 & currentState)))
    {
        Trackball.directFlags |= (BUTTON | BTN_DOWN);
        Trackball.buttonPress = true;
        Trackball.dataAvailable = true;
    }
    if ((0x00 == (0x01 & prevState)) && ((0x01 & prevState) != (0x01 & currentState)))
    {
        Trackball.directFlags |= BTN_UP;
        if (BTN_DOWN == (BTN_DOWN & Trackball.directFlags))
        {
            Trackball.buttonPress = true;
        }
        Trackball.dataAvailable = true;
    }
    prevState = (0x03 & currentState);
}
19  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 01:16:30 am
No timer interrupts. External and pin change interrupt only. Thanks for the tip on atmel studio. I will definately try that. I like atmel studio MUCH more than the arduino IDE.
20  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 01:05:18 am
Specifying where my isr's are to be placed looks like the simplest solution however, for some reason my atmel studio got screwed up (I don't know how) and it can't find the arduino files at compile time so I can't compile arduino sketches now.  smiley-mad I've completely uninstalled atmel studio, visual micro for atmel and ardiuno IDE, deleted the folders for all three, re-downloaded and installed all three and still have the same problem. I noticed in the output window the errors it refers to are looking in the sam folders not the avr ones. I have the correct board, port and IDE set. In fact I checked all the settings and nothing is set for the sam. The weird thing is, I can write and compile arduino libraries just fine.  smiley-confuse I'm probably getting quite off topic here so I'll stop now.

DJ
21  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 12:50:55 am
Would it make a difference if I didn't use attachInterrupt() and instead set the registers myself and used ISR() for my interrupts? Or is that the same thing attachIterrupt() does? The reason I ask is because changing the interrupt code would be easier than changing the progmem code (fewer lines of code to edit).

DJ
22  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 12:25:23 am
So, is placing the progmem stuff in far memory going to be the solution here? Is this really being caused by progmem forcing the relacation, or are my ISR's the problem? I'm using attachInterrupt() instead of directly setting the registers. I haven't looked into what attachInterrupt() does under the hood. I've had sketches >70K running no problem. Why the relocation of vectors in particular? Aren't where the vectors are placed in memory set according to fuses, or did I misunderstand the data sheet? I'd hate to change all the progmem code, then later find out that wasn't the root cause.

Thanks again for your replies,
DJ
23  Using Arduino / Programming Questions / Re: Strange error message on: April 14, 2014, 11:26:27 pm
Thank you pYro!

I thought it had something to do with progmem. When I first saw the error message the "relocation" part caught my attention. I thought, why would anything need to be relocated and what would cause such an event? The only large things in my code are the fonts and some text arrays (also in progmem). That's where I started to debug. I needed the text arrays so I started with the fonts and Arial_bold_14 was the largest, so I started there and viola... fixed.

The sketch without that particular font is ~28K. It wouldn't compile with the font so I didn't get a size, but the font is 8712 bytes so, just over 36.5K with it. That still seems like it shouldn't be a problem. I'm also using ~2100 bytes SRAM (only 26%). That shouldn't have any bearing on flash memory should it?

At least I was on the right path. I'll try putting the fonts and text in far memory and see if it works. Thanks again for confirming my conclusion. This isn't the first (and won't be the last) time you've helped me with your insight.  smiley

DJ
24  Using Arduino / Programming Questions / Re: Strange error message on: April 14, 2014, 09:25:57 pm
Sorry for not replying sooner. The point is moot. I found out what was causing the error, and to answer your questions; The error occured at compile time, I beleive at the linker stage (not positve about that). I'm using a Mega2560 r2 and the latest IDE 1.5.6 r2. The program is a pool controller that uses the following libraries: DallasTemperature, OneWire, I2C, glcd and a modified (by me) version of DS1307. The sketch is large and will not fit here in the forum. I was going to put all the relative files in a zip to post however, I discovered the cause of the error. It is related to the glcd library and one of it's included fonts (Arial_bold_14.h). Once I changed the font everything's ok. If someone is really curious and likes to figure out problems, I'll take the time to zip all the files and post. There is still one thing I would like to know for future reference. What the error message means. I use interrupts in my sketch, but they have nothing to do with the glcd library or its fonts. Does it have something to do with the fonts being located in progmem? If so, why does it work after only changing the font used?

What I was asking in my OP wasn't "why isn't my code working?". It was "What does this error message mean?". For instance, you don't need to see any code to know what this error means,

Quote
error: new declaration 'uint8_t foo(uint8_t)'
error: ambiguates old declaration 'void foo(uint8_t)'

 Anyway the point is moot now, it's working. It's just curiosity that interests me.

Thanks for the reply.
DJ
25  Using Arduino / Programming Questions / Re: Strange error message on: April 13, 2014, 07:29:25 am
Has anyone ever seen this before? Anyone on the arduino team perhaps? Someone has to know what it means. Right?  smiley-roll
26  Using Arduino / Programming Questions / Strange error message on: April 13, 2014, 06:08:47 am
Can someone please explain to me what this error message means so I'll have a clue as to what is going on.

The error is:

c:/program files (x86)/arduino-1.5.6-r2/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o: In function `__vector_default':
(.vectors+0x3c): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_15' defined in .text section in c:/program files (x86)/arduino-1.5.6-r2/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o

I don't have any idea what it means, so any hints would help. Mostly, I would really like to understand what the message means. For instance, what is this (.vectors+0x3c): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_15' defined in .text section all about? Relocation... Huh?
27  Using Arduino / Programming Questions / Re: Why == works in an if statement? on: April 07, 2014, 01:36:10 pm
Also, it's a good habit to put the constant before the variable it's being compared to.
i.e.
Code:
if (25 == a)
{
    // Some action here
}
The reason for doing this,
Code:
if (25 = a)
{
}
Will cause a compiler error. Because you're trying to assign a variable to a constant. This coding habit will catch your error where, if you put = but meant == (a very common mistake). If you do a = 25 it will compile, but obviously not what was intended.
28  Using Arduino / General Electronics / Re: Analogue/Digital ground planes on: February 02, 2014, 12:17:24 pm
Have a look at the file I've attached below. (Circut Board Layout Techniques.pdf) It's pretty informative.

I hope this helps,
DigitalJohnson
29  Using Arduino / Programming Questions / Re: Questions about class syntax. on: February 01, 2014, 01:14:35 pm
Thanks for knowledge guys. As always, (I'm quoting South Park here) I think I've learned something today.  smiley-wink

C-Ya,
DigitalJohnson
30  Using Arduino / Programming Questions / Re: Questions about class syntax. on: February 01, 2014, 12:47:37 pm
I have another question (actually two). Can initializer lists be used with methods/functions? Can the x(y) syntax of assignment be used elsewhere as well? Not that I'd want to, because obviously for others like myself, it's function seemed to be ambiguous where as with y = x it's very clear what's going on. When I first saw it I thought it was as in mathmatics. Where x(y) would mean y multiplied by x. Now that I think about it, do you have to use that syntax in initializer lists, or can you use y = x instead?
Pages: 1 [2] 3 4 ... 11