Add big data chunk to flash memory during programming?

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
jumper
Posts: 466
Joined: 07 Mar 2007 14:36

Add big data chunk to flash memory during programming?

#1 Post by jumper » 10 Jul 2018 04:12

Hi,

I have a project where today we have around 12000 bytes of data stored in a file on a SD card that the PIC is reading. Now I want to move that data into the flash memory since I anyway have enough space for it.


What is the best way of getting the compiler to add the data into the program memory when I build the project. How and where should I put the data I want to include an how to specify the memory addresses?

I have seen examples on how to include EE2 data when programming but I have not seen any flash examples.

Anyone any ideas?

User avatar
petar.suknjaja
mikroElektronika team
Posts: 683
Joined: 05 Mar 2018 09:44
Location: Belgrade

Re: Add big data chunk to flash memory during programming?

#2 Post by petar.suknjaja » 11 Jul 2018 16:13

Hi I think we talked about this on helpdesk,

However, I encourage our users to think about it and maybe some one could have some idea about this.

Kind regards,
Petar

ira
Posts: 22
Joined: 14 Feb 2013 20:04

Re: Add big data chunk to flash memory during programming?

#3 Post by ira » 20 Jul 2018 03:37

When I needed to do this, I wrote a program, in those days in Cliipper, today I'd use VB, that generates a header file with the data as a long constant string or array and then just #include that file where needed.

table.h looked like this:


dt 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
dt 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
dt 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47
dt 48, 49, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64
dt 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80
dt 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96

and then the .asm file looked like this:


; This is where the conversion data starts
; Up there we set PCLATH to the page we want to look in
; here we add jump to PCL to get the correct byte from the selected page
; The org has to start 2 bytes before the beginning of a page so if jump is zero
; the first byte of the selected page is returned. i.e., PCL must be 0xFF when
; addwf PCL,F is executed
org (TABLEBANK0*0x0100)-2 ; 0x2fe
tables: ;0-255
movf jump,W
addwf PCL, F

#include "table.h"

This worked in assembly, must also be possible in C, just don't know how.

Ira

ira
Posts: 22
Joined: 14 Feb 2013 20:04

Re: Add big data chunk to flash memory during programming?

#4 Post by ira » 20 Jul 2018 17:13

I think in C you will need to write it at a number of consecutive arrays of const chars, preferably specifying then as in flash if that's possible. Then you'll need to write some sort of access routine to get to the data you need. Conceptually it could be one long array but I've no idea if the compiler can handle that. As long as they are consecutive in memory you can access them using only the first array reference as C is happy to read past the end of an array.

Ira

Post Reply

Return to “mikroC PRO for PIC General”