Pages: 1 [2]   Go Down
Author Topic: I'm out of memory? Is the next thing up the Mega644P?  (Read 2169 times)
0 Members and 1 Guest are viewing this topic.
the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Code:
//keep track of time and handle millis() rollover
boolean timer(unsigned long timeout)
  {
    return (long)(millis() - timeout) >= 0;
  }

The rollover business is fairly subtle. As I recall, the code in the BlinkWithoutDelay example
works correctly [although it does look like they declared previousMillis poorly]. Other forms
may look correct, but will give incorrect results. It pays to feed in a few values near the
rollover value and test the different forms.
Code:
long previousMillis = 0;        // will store last time LED was updated

void loop()
{
  unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }
}
Logged

0
Offline Offline
Sr. Member
****
Karma: 4
Posts: 289
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


I also wrote up a page discussing my fixes and experiences,
http://www.ot-hobbies.com/resource/ard-1284.htm

I just read through your link and it is fantastic!  I am wondering though, does any of this matter with regards to the package that I choose?  I am trying to fit this all onto a fairly small board so I probably won't use the pdip version of the 1284P.  If I am feeling brave I may go for something as small as the QFN package as I have had a lot of success hand soldering a 4mmx4mm QFN10 package and I think I may be okay soldering something that is materially bigger than that.
Logged

Arduino Uno;
Mega328

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think most of those items will still be applicable, except possibly the RX0
problem. Depends on whether the RX0 pin is located adjacent to the
Oscillator-in pin on the chip you use. Also, maniac bug still hasn't fixed
the Bobuino variant file. And you will still need to check all of the
library files for proper 1284 support.
Logged

0
Offline Offline
Sr. Member
****
Karma: 4
Posts: 289
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think most of those items will still be applicable, except possibly the RX0
problem. Depends on whether the RX0 pin is located adjacent to the
Oscillator-in pin on the chip you use. Also, maniac bug still hasn't fixed
the Bobuino variant file. And you will still need to check all of the
library files for proper 1284 support.

Excellent!  Thanks!
Logged

Arduino Uno;
Mega328

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 548
Posts: 27393
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I believe this file has the Bobuino issues fixed - its the one I use with my boards.
I have comments in to show the two lines that were changed.

* pins_arduino.h (6.26 KB - downloaded 10 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Good to hear, Bob. But will the github library files ever get fixed? $64 question.
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 548
Posts: 27393
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Who knows. Can anyone access them besides Maniacbug?
Maybe time to copy them into a new area and start referencing that instead.

Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Who knows. Can anyone access them besides Maniacbug?
Maybe time to copy them into a new area and start referencing that instead.
Ah! Truly excellent idea - time to fork the library and fix the bad boys.

The slight problem with this is how to get the word out that the library has been
forked, so people use the correct version. --> ????

Along these lines, I've recently been using MP-IDE and the ChipKit libraries for the
PIC32 [roughly Arduino compatible], and "belatedly" discovered there are 2 forked
libraries and both have the identical same name, and with just a few files different
- this is a HUGE bummer. I lost a couple of days because of this silliness.

https://github.com/EmbeddedMan/PIC32-avrdude-bootloader <-- bad one.
https://github.com/EmbeddedMan

https://github.com/chipKIT32/PIC32-avrdude-bootloader <-- good one.
https://github.com/chipKIT32

So, if the library gets forked, someone should have the friggin sense to also
change the name a bit, to help clarify things.
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 548
Posts: 27393
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, calling it a new name and posting about in the forum would help.
Not sure how else folks come across it.

Call it something else besides mighty1284, just need to tweak a few names in the variant folder & pins_arduino.h, shouldn't take much. Like make it all Mega1284P, and keep Bobuino the same. Can add 164P, 324P, and 644P variants as well.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I figure you're the guy, since the big the problems are in the Bobuino variant,
plus I've never used any of those other processors myself, :-). Then, we can
stop referencing the bug library, along with wasting time over and over telling
everyone to beware of the bugs, ad nauseum, and can refer them to a fixed
library.

The name wouldn't have to be too different, just enough so that you don't
have 2 different libraries with the same name on your HD, and wondering which
is which.

If it were me, I'd change the library name, and also the name of the primary .h
file at least. This bugs me about the nRF2401, RFM12, and RFM22 libraries, is
that everyone picked such similar names for completely different RF modules,
all the way down to the .c and .h files.
Logged

0
Offline Offline
Sr. Member
****
Karma: 4
Posts: 289
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I plan to order the PDIP version of the 1284P on my next mouser purchase so that I can breadboard my project and hopefully I can try out some of these fixes.
Logged

Arduino Uno;
Mega328

Offline Offline
Sr. Member
****
Karma: 11
Posts: 356
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I sorry for the late response I forgot about this topic but I must inform you that there are several ways to optimize the program posted at https://github.com/jerseyguy1996/Leslie_GPS_Breadboard/blob/master/Leslie_GPS_Breadboard.ino
The Serial library is very bloated and in all honesty sucks. Replace the Serial.function with these functions
Serial.println can be replaced with this function
Code:
inline void serialWrB(uint8_t dat){
UDR0=dat;
while ( !( UCSR0A & (1<<UDRE0)) ) {} //wait for byte to transmit
}
void StringPgmln(char * str){
do {
serialWrB(pgm_read_byte_near(str));
} while(pgm_read_byte_near(++str));
serialWrB('\n');
serialWrB('\r');
}
Code:
Serial.println("Button Pressed");
becomes
Code:
StringPgm(PSTR("Button Pressed"));
The problem with the serial library is the text is stored into the ram even though the strings are constant. My code stores it in the flash memory.
If you want to send text from the ram use this code
Code:
inline void StringSerialln(char * str){
do {
serialWrB(*str);
} while(*(++str));
serialWrB('\n');
serialWrB('\r');
}
An usage example of this function is
Code:
uint16_t x=analogRead(a0);
char buf[5];//max digits + 1
utoa(x,buf,10);
StringSerialln(buf);
Only use the StringSerialln for non static strings
Also you must remove Serial.begin too so change
Code:
Serial.begin(115200);
with
Code:
UBRR0H=0;
UBRR0L=16;/*These values assume double speed is enabled (see below) and a 16mhz clock is used 3 = 0.5M 2M baud rate = 0 7 = 250k 16 = 115.2k 207 is 9600 baud rate*/
UCSR0A|=2;//double speed aysnc
UCSR0B = (1<<RXEN0)|(1<<TXEN0);//Enable receiver and transmitter
UCSR0C=6;//async 1 stop bit 8bit char no parity bits
Note if your processor has multiple uart outputs change the number from 0 to whatever you want. If you are using an arduino board the one that gets sent to the usb is 0.
That should save some space I can suggest more optimizations if it still does not fit on whatever processor you have.
« Last Edit: July 24, 2013, 04:51:46 pm by Mr_arduino » Logged

Pages: 1 [2]   Go Up
Jump to: