Insufficient Storage. Efficient Memory. Stm32f103c8t6.

Hello all ,

I am using Stm32f103c8t6 with Offical core with HID bootloader. I am working on Visual Studio Code IDE using Microsoft Arduino Extension.

I have a few PCBs with several Functional blocks mounted in Stm32f103c8t6. I will describe one of the boards with all functional blocks on it.

The board has 6 General Purpose Output (using built internal GPIO pins) with all necessary electronics to drive up to 24 volts. It also has 4 analogue industrial inputs (using external ADC pins via I2C1 communication (ADS1115 IC with all necessary electronics to read the voltage up to 10 volts. Then, the board has 6 PWM using BTN8962TA ... 2d247a7bf5 to drive the motors using PWM frequency and Dutycycle using the outputs from PWM. To be noted for all the 6 PWMs, from the schematics of the board there are two external ADC pins(one for I sense, and V sense(using ADS1115 IC via I2C1)), one external GPIO pin(for Inhibit pin of PWM(using MCP23017 IC ... 01952C.pdf via I2C1)), and an internal timer pin connected to PWM directly from the microcontroller. Then there are 5 thermocouple pins using MCP9600 IC ... 02417A.pdf via I2C1. Then, the board has 3.3 to 5V I2C1 pins to use Sensirion SCD30 Sensor Module ... 510853.pdf. Also, it has compatibility to support NeoPixel LED. Also, SPI2 is available for using an SD card and touch screen to work it as HMI. Above all that it also has its I2C2, USART1, USART2, LIN.

When I created my own library for 6 General Purpose Output, 4 analogue industrial inputs, and 6 PWM with the help of all the available Arduino libraries for all electronic components. After creating it and I tried to check all the functionality I have made in my library in the .ino file using my library. It worked pretty well.

Then I added more functionality in my library like just adding 5 thermocouples in my library with its available Arduino library and integrating them into my library. Now, when I ran my .ino file, the program crashes the Stm32f103c8t6. Now, I had rebooted my Stm32f103c8t6 again to use it again.

After this, I noted that just adding functionalities till itself takes up almost 80% of the storage out of 64Kbytes.

I have some questions here!
Why did my MCU is crashing when I upload a program?
Can I utilize the whole storage of my MCU?
I wanted to create a general-purpose Library to use the PCB as desired with minimal coding in the .ino file. So, is that possible?
How maximize the storage in MCU?
How to use the storage efficiently?

I have explained all my hardware things here, just give more clarity on what I am trying to achieve with what and how!

I hope to get your suggestions, opinions, guidance, directions, and references to achieve my task.

Thanks in advance.