I’ve been attempting to use the Atmega328P as a sort of intermediary that processes requests from a computer and sends commands to an Adafruit GPS (MK3339) unit, then saves the data to EEPROM. I’m still testing a few things, and I do plan to change the design (such as adopting an external EEPROM), but anyway, that’s the rough context.
So far, things have been peachy – but as I’ve started integrating control elements to allow changes during runtime (chip gets a request over serial, trips a switch, sends back a dump of EEPROM contents), I’ve run into memory issues, specifically with the SRAM.
The problems I’ve observed and things I’ve done.
Running the sketch and sending messages to the chip over serial is fine initially, but then the second message ends up crashing the chip (so I gather since it resets automatically).
I ran some tests to check the RAM usage and got the following numbers (Point 1:1073, Point 2 :-1219). Point 1 being before the CarryOutCommands function, Point 2 aftewardsr. So I’m definitely exceeding the RAM’s capacity, right?
I’ve optimised the code to the best of my knowledge, but it’s possible I might have overlooked or mistaken something. I think the CarryOutCommands function is suspect; I feel I’m overthinking what should just be a simple operation.
I’m a little lost at the moment in regards to my options. Either I’m carrying out the optimisation incorrectly (probable), or it would be better to just upgrade to something with a bit more memory than an Atmega328P to fit my needs.
((I’ve added the code as an attachment since it wouldn’t let me paste it in here)).
draftCode_arduinoGPS.ino (7.89 KB)