Jump to content

Recommended Posts

So having finally got to the point now where we need to do projects with the PIC32 (actually, the problem is RAM, not processing power, but you might as well make the step to 32 bits) and start the process of porting things to the Microchip compilers.

 

It reminds me what a joy it is to work in the clean, straightforward world of Sourceboost. Let's ignore the fact that MPLAB is extremely unfriendly and confusing, or the fact that you can easily (accidentally) spend ages reading help files only to realise that the help is for the HITECH C compiler and not the C18 compiler (or the XC8 compiler, which appears to be HITECH, full of bugs, and also an incompatible syntax with C18!)

 

Try and find out how much memory (flash and ram) a given function uses in MPLAB. Go on. I dare you.

 

It does appear to use less flash - a sample program I tried used considerably less flash but three times as much ram,. but then I'm just beginning on this journey. My first guess from looking at why is that C18 clumps all the ram constant assignments such as strings into flash, and then zaps them all into ram using table reads at the start of the program - meaning that it uses all that ram from the start, but uses less flash since this is a more efficient way of storing data than SourceBoost's equivalent:

 

 

serial_print_str("x: print my_var=0x");

03B8 0E20 MOVLW 0x20

03BA 6E37 MOVWF CompTempVar728+D'2'

03BC 6E3D MOVWF CompTempVar728+D'8'

03BE 0E30 MOVLW 0x30

03C0 6E45 MOVWF CompTempVar728+D'16'

03C2 0E3A MOVLW 0x3A

03C4 6E36 MOVWF CompTempVar728+D'1'

03C6 0E3D MOVLW 0x3D

03C8 6E44 MOVWF CompTempVar728+D'15'

03CA 0E5F MOVLW 0x5F

03CC 6E40 MOVWF CompTempVar728+D'11'

03CE 0E61 MOVLW 0x61

03D0 6E42 MOVWF CompTempVar728+D'13'

 

...which happens at run time, when it's needed. Uses more flash, but saves on ram.

 

Still.

 

It would be so nice if we had a PIC32 version of Sourceboost.

Share this post


Link to post
Share on other sites

Hi

 

Setting up a table or tables of data in flash and them dumping them to RAM at the startup is a technique commonly used by compilers that provide variable initialization (RAM value), either default or explicit.

 

Just out of curiosity, do you already exausted memory space in the PIC18 family?

Including the Extended and Microprocessor modes with external memory?

 

Best regards

Jorge

Share this post


Link to post
Share on other sites

Hi Jorge,

 

The PIC18F8X20 range of devices do have an external memory interface - but they only run at 10MIPS, which is not quite enough for our applications.</p>

 

It's the RAM that's really the problem, I would swap half the flash for more than 4k of RAM. Still, getting more than 16MIPS of performance would certainly help too.

 

cheers

Ian

Share this post


Link to post
Share on other sites
It's the RAM that's really the problem, I would swap half the flash for more than 4k of RAM. Still, getting more than 16MIPS of performance would certainly help too.

 

Could you just write a strcpy_from_flash_to_ram() function, which copied/unpacked the string data from flash into a designated RAM location or string pool area?

 

Another option would be to set up a set of string functions that allowed the source strings to be in flash or RAM (destination would always need to be RAM, though). For example, it's common with the lower end processors such as 16F etc to pack strings in A2 (2 ASCII bytes per word in flash), and then copy/unack these to RAM as needed.

 

hth

 

don

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...