Background: I have a pretty basic project that is a fork of another project based on the LeonardoCAN board from Hobbytronics. That project uses the MCP2515 chip onboard to the LeonardoCAN, and an SSD1306 OLED display driven over SW or HW SPI (D10-13).
Im converting this to use the same MCP2515 CAN chip but offboard via SPI (D10-13), and an SSD1306 OLED display driven by I2C (A4&5)
Hardware: Arduino Uno, MCP2515 CAN chip w TJA1050 interface (D10-13), SSD1306 128x64 OLED display (A4&5)
Problem: This is where it gets strange, i can initialise everything just fine except when it comes to filtering the CAN input using init_Filt from mcp_can.h (Seeduino shield library). However, the means of failure is super odd. If it was an issue with the filtering function I would expect it to fail in the loop() section of code. But whenever the init_Filt function is present within the codebase it fails in setup() with the display.begin() function [line 82], and never gets to executing the offending init_Filt() [line 184]. This is super odd, because logically the call to init_Filt() should only occur after the display has been initialised on line 82 with display.begin().
I have already tried trimming down the code base to just the SSD1306 and MCP2515 relevant sections in case it was a memory error, but to no avail. Both the MCP2515 and SSD1306 example code run flawlessly.
Im a bit stumped (could be because im groggy with cold and flu tabs), but I cant think of why adding a function into another portion of the codebase causes a failure in setup(). Unless the micro is simply running out of SRAM when it is allocating the memory for display.begin()
Code is available here: EliteGaugeDiscrete/Elite_Gauge_Pro.ino at master · porterble/EliteGaugeDiscrete · GitHub
Help?
SOLVED: Malloc issue, see post #4