Show Posts
Pages: [1] 2 3 ... 10
1  Using Arduino / Programming Questions / Re: Strange error message on: April 17, 2014, 06:57:15 am
Oops. smiley-roll I saw 4096 and my mind converted that to 4K and skipped the k that was there. Great, will attach.
2  Using Arduino / Programming Questions / Re: Strange error message on: April 17, 2014, 05:39:43 am
@pYro_65

Sorry for not getting back sooner. Something came up and I couldn't get to this until now. I haven't commented the files as well as I'd like to have. Included in the attached folder are two zips and a readme.
Obviously, read the readme. If you have more questions, you can PM me or reply here. This topic will notify me by email. Good luck. smiley-eek

PS
Hold on, The folder is 2MB and apparently an attachment can't be larger than 4K. So, if you're still interested I can email it to you, or if you have another method of getting the files, I'll do that. Let me know.


PPS
nevermind PS, it is attached to my next post.

Thanks for your time and help,
DigitalJohnson
3  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 10:32:46 pm
OK. It looks like you're in Australia. It's 8PM here in California and I'm about to have dinner. I'll try to post tonight, but no promises. If not, it'll be there in the early morning (around noon to you). I'm glad I'm not the only one driven by the need for resolve.  smiley-razz

Thanks for the added effort pYro. Maybe we'll all learn something. I think there's a 60% chance the cause will be something unexpected. But then again, I've only been coding C/C++ for 4-5 years or so. smiley-roll

Thanx,
DJ
4  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 02:21:08 pm
I've made the changes you suggested below. I used both 9 and 10 with the same result.

Code:

void isrUp(void)__attribute__ ((section (".text")));
void isrDown(void)__attribute__ ((section (".text")));
void isrLeft(void)__attribute__ ((section (".text")));
void isrRight(void)__attribute__ ((section (".text")));

extern "C"{
  __attribute__ ((section (".text"))) void __vector_10(); // PCINT0 is vector 10 in the data sheet
}


Same error message.  smiley-confuse smiley-sad

As I was digging through all of the libraries and relavant core files I noticed something odd I hadn't noticed before. You even asked me early on if I was using Timer2. Nowhere in my code or related libraries do I use interrupt vector 15. So, at this point I'm going to try the progmem far memory thing, as the extra instruction cycle overhead won't be a problem.

As I stated at the start of this thread, If anyone is curious about what is going on here, I'll take the time to zip up the sketch files and all the related libraries (at least the ones I've modified [I'm sure none of them are related to this problem]) and post it. It's a small chore to gather it all up, place better comments everywhere (I use my own short hand before I share), zip it all up and then post. So, if no one wants to try and figure it out just for the challenge, I won't bother. Personally, I'd like to know what's using the timer interrupt. As far as I can tell nothing should be. It's things like this that will make me revisit the issue someday, just to know why.

I hope putting the fonts and strings in far memory fixes the problem. If not, I'll stick with the smaller font as that compiles fine for now. I'll just have to squint when I'm further away. (further or farther?) I'll post back and let you know if far memory does the trick.  smiley-wink

Again thanks for the help,
DJ
5  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 12:34:26 pm
I was just about to ask you, what if I place prototypes for my ISR's in the code you gave. You answered before I could post. I will give this a try and let you know.

PS.
This might take a short amount of time. I need to modify my sketch so I get the error again, then make the change you suggest. I'll be back! smiley-cool
6  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 12:23:30 pm
Sorry, I was in the middle of writing and posted before I saw your new post. So I'm a little lost about what your referring to. Try what on the offending ISR? Also, what is the output you're showing/what does it mean?
7  Using Arduino / Programming Questions / Re: Strange error message on: April 15, 2014, 12:18:50 pm
OK, I've read the AVR Libc user manual sections; Memory Areas and Using malloc() and Memory Sections. This is all stuff I've never done before, but that doesn't mean I'm not going to try. However, it does mean I'm going to have more questions (you probably saw that coming  smiley-razz).

I've copied the code you posted and it compiles fine. Now, if I place this code before setup() in my sketch, where do I place my ISR's (in the code you provided) to insure they are close enough to the vector table? I'm guessing right before the while loop after the USB stuff. Correct? 
8  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
9  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
 
10  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);
}
11  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.
12  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
13  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
14  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
15  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
Pages: [1] 2 3 ... 10