Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC16F685 flowcode programming - Any Flowcode experts?

Status
Not open for further replies.

E-design

Advanced Member level 5
Joined
Jun 1, 2002
Messages
2,014
Helped
507
Reputation
1,016
Reaction score
408
Trophy points
1,363
Activity points
14,193
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
 

flowcode tutorial

I think I found a much simpler method I am going to try but I am still open to suggestions.

edit:

It looks like the floating point calc was the problem. Managed to get the whole program including the macro down to 1540 bytes by not using any floating point.
Old method used the traditional way of div by 2 and check for remainder. Now I just subtract using int and byte type variables.
 

display macro flowcode

Hi Friend

Here is proper Floating Point Math Library for flow code with example included

regards
Fragrance
 

where is flowcode used

Fragrance, thank you.

But I see that this simple floating point example you gave still uses 2888 words when compiled. That explains why my first attempt used over 5k

Building CASM file
Memory Usage Report
===================
RAM available:368 bytes, used:97 bytes (26.4%), free:271 bytes (73.6%),
Heap size:271 bytes, Heap max single alloc:95 bytes
ROM available:8192 words, used:2888 words (35.3%), free:5304 words (64.7%)
 

flowcode examples

Here is more complecated example of floating math with string

regards
Fragrance
 

flowcode macro example

These are nice routines but they all consume a lot of program memory. Too much for a small chip like the 16F677 like I wanted to use.

The String to Float

Building CASM file
Memory Usage Report
===================
RAM available:368 bytes, used:126 bytes (34.3%), free:242 bytes (65.7%),
Heap size:242 bytes, Heap max single alloc:95 bytes
ROM available:8192 words, used:4404 words (53.8%), free:3788 words (46.2%)

Float to String

Building CASM file
Memory Usage Report
===================
RAM available:368 bytes, used:126 bytes (34.3%), free:242 bytes (65.7%),
Heap size:242 bytes, Heap max single alloc:95 bytes
ROM available:4096 words, used:3318 words (81.1%), free:778 words (18.9%)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top