How to optimize code generation for Arduino Uno for Tune&Monitor?

6 views (last 30 days)
(After few tries, I have updated the end of this post)
I just adapted the following arduino Code to display the character 'A' on a Nokia 5110 LCD screen. The arduino code is:
// Test to write a single character
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);
void setup() {
void loop() {}
void testdrawchar(void) {
display.write(65); //display the character 'A'
The debugger provide the following output once compiled for Arduino Uno:
Sketch uses 8032 bytes (24%) of program storage space. Maximum is 32256 bytes.
Global variables use 884 bytes (43%) of dynamic memory, leaving 1164 bytes for local variables. Maximum is 2048 bytes.
The simulink code consist of : a contant uint8, a converter uint8, and a S-function I build with the s-function buillder.
I can build it, and deploy it succesfully:
Device: atmega328p Program: 16280 bytes (49.7% Full) (.text + .data + .bootloader) Data: 868 bytes (42.4% Full) (.data + .bss + .noinit) ### Deployed code to target successfully ### Successful completion of build procedure for: Nokia5110_Sfunction ### Simulink cache artifacts for 'Nokia5110_Sfunction' were created in 'C:\...\Nokia5110\Nokia5110_Sfunction.slxc'.
Build process completed successfully
I have improved the code using a slider to change the constant uint8. The build and deploy is succesful. However, the Tune and Monitor is throwing this error:
AVR Memory Usage ----------------
Device: atmega328p
Program: 38608 bytes (117.8% Full) (.text + .data + .bootloader)
Data: 1446 bytes (70.6% Full) (.data + .bss + .noinit)
### Build procedure for Nokia5110_Sfunction aborted due to an error.
The following error occurred during deployment to your hardware board: The generated code exceeds the available memory on the processor. It uses 117.8% of available program memory and 70.6% of available Data memory.
How can I optimize the code to make it tuneable from an arduino uno ?
  1 Comment
Sylvain on 15 Dec 2020
while waiting for a reply, I have tried an Arduino Due, and the Tune-monitor works. I think I was facing a Hardware limitation.

Sign in to comment.

Answers (0)


Find more on Simulink Coder in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!