E-design
Advanced Member level 5
flowcode programming
I have a macro that does sort of a byte number to binary converion as explained below. The routine works but takes a lot of memory. I am using a PIC16F685
Object of this routine is to take a byte number between 16 and 240
(11110000 and 00010000) and convert the number to binary display.
I only need to display the status of any of the upper 4 bits (0001 to 1111)
I also need to display the leading zero's in this application.
This routine works but chew a lot of ROM which must be because of
the floating point calculations I use.
The variable "bin" is my converted number (without leading zero's)
I add any leading zero's in another nested IF block depending on the number
range. So I will add "0" or "00" or "000" and then print the "bin" value.
This is the size this macro compiles to 4119 words!
This macro alone takes all this memory, so I am looking for
a routine to do this taking as little as possible space
My target is about 3k max as I need about 600 bytes for the main program.
Building CASM file
Memory Usage Report
===================
RAM available:256 bytes, used:185 bytes (72.3%), free:71 bytes (27.7%),
Heap size:71 bytes, Heap max single alloc:70 bytes
ROM available:4096 words, used:4119 words (100.5%), free:-23 words (0.-5%)
Too much code to fit in ROM, overfilled by:23 locations.
I attach the code for this macro wth comments. If anyone has a idea how this code can be optimized or another routine I will be very glad. I don't want to go to a bigger chip. Programming is not my strong point!
The pdf is my flow chart of this macro
Thanks
I have a macro that does sort of a byte number to binary converion as explained below. The routine works but takes a lot of memory. I am using a PIC16F685
Object of this routine is to take a byte number between 16 and 240
(11110000 and 00010000) and convert the number to binary display.
I only need to display the status of any of the upper 4 bits (0001 to 1111)
I also need to display the leading zero's in this application.
This routine works but chew a lot of ROM which must be because of
the floating point calculations I use.
The variable "bin" is my converted number (without leading zero's)
I add any leading zero's in another nested IF block depending on the number
range. So I will add "0" or "00" or "000" and then print the "bin" value.
This is the size this macro compiles to 4119 words!
This macro alone takes all this memory, so I am looking for
a routine to do this taking as little as possible space
My target is about 3k max as I need about 600 bytes for the main program.
Building CASM file
Memory Usage Report
===================
RAM available:256 bytes, used:185 bytes (72.3%), free:71 bytes (27.7%),
Heap size:71 bytes, Heap max single alloc:70 bytes
ROM available:4096 words, used:4119 words (100.5%), free:-23 words (0.-5%)
Too much code to fit in ROM, overfilled by:23 locations.
I attach the code for this macro wth comments. If anyone has a idea how this code can be optimized or another routine I will be very glad. I don't want to go to a bigger chip. Programming is not my strong point!
The pdf is my flow chart of this macro
Thanks