The Godfather talking
Share your stuff or I will make you regret it.
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 05, 2016, 11:26:32 11:26


Login with username, password and session length


Pages: [1]
Print
Author Topic: Anyone know how to reserve a specific block of flash rom?  (Read 6793 times)
0 Members and 1 Guest are viewing this topic.
tzehon
V.I.P
Newbie
*****
Offline Offline

Posts: 11

Thank You
-Given: 2
-Receive: 1


« on: November 29, 2009, 09:36:10 21:36 »

Hi everyone,
May i know how can i  reserve a specific block of flash rom in known address?
In other word, i want to do something like #pragma romdata (CCS C) in mikroC.

Thanks in advance

tzehon
Logged
msamar
Newbie
*
 Muted
Offline Offline

Posts: 28

Thank You
-Given: 0
-Receive: 4


« Reply #1 on: November 29, 2009, 11:13:30 23:13 »

hello
no you can't allocate memory rom on mikroC for data yet maybe next 50 years

only for all program like
Code:
#pragma orgall <addr>

or make function allocation like

Code:
void func(int par) org 0x200 {
// Function will start at address 0x200
  asm nop;
}

or use this old trick
Code:
const unsigned char cvar[]= {1,2,3,4}absolute 0x100;// allocate data on rom

regards amar
« Last Edit: November 29, 2009, 11:18:41 23:18 by msamar » Logged
tzehon
V.I.P
Newbie
*****
Offline Offline

Posts: 11

Thank You
-Given: 2
-Receive: 1


« Reply #2 on: November 30, 2009, 04:46:34 04:46 »

Hi,

Thanks Amar .

Code:
const unsigned char cvar[]= {1,2,3,4}absolute 0x100;// allocate data on rom

By using this old trick , how can i retrieve the allocated data from the rom and can i change allocated data with Flash_Write ?

tzehon
Logged
msamar
Newbie
*
 Muted
Offline Offline

Posts: 28

Thank You
-Given: 0
-Receive: 4


« Reply #3 on: November 30, 2009, 09:31:20 09:31 »

Hello tzehon
Listen please if you are familiar with  mikroC compiler, first you should be professional on ASM programming otherwise the time rings a bell I advise you stop using this compiler . CCS better on that you should be professional on C programming . about me I don’t prefer any !?............<it’s up to my business>

Ok don’t worry what kind of version did you use
an old ver  mikroC Version: 8.2.0.0 I think its good
ore an new mikroC pro 3.2 its full of bugs !

please write to me which one ?
regards amar

 

   
Logged
tzehon
V.I.P
Newbie
*****
Offline Offline

Posts: 11

Thank You
-Given: 2
-Receive: 1


« Reply #4 on: November 30, 2009, 01:53:44 13:53 »

Hi, i am using mikroC for dsPIC30f/33f. I using mikroC because of its powerful library, but i don't know they have neglected such a basic feature/directive of a compiler. Btw, i am a beginner of C and ASM. FYI, what i want to do is storing a string in a flash memory (ROM) and be able to retrieve them to RAM for comparison, and be able to change the string by flash the memory (ROM) RTSP using flash_write function provided by mikroC.

Thanks for any help given.

tzehon
Logged
msamar
Newbie
*
 Muted
Offline Offline

Posts: 28

Thank You
-Given: 0
-Receive: 4


« Reply #5 on: November 30, 2009, 04:52:36 16:52 »

Hello
I was thinking that you are working on 16f or 18f series
Yes that good idea don’t track asm codes if you turn to dspic MCU
Its very hard to study asm command when you move to new series of micro controllers
About me during my business trip  like ARM, renesas  ,AVR , PIC its very hard to study asm command for every MCU you working with we have to study only C programming and looking for good compiler use it after PIC 18f series I have moved to renesas MCU
Belong to Renesas Technology Corp Visit www.America.Renesas.com

H8 microcontrollers are designed to
deliver high throughput for excellent
application performance.
For example, their CISC CPU cores
execute most instructions in just one
clock cycle, and their Advanced
Data Management peripherals
utilize a 3-bus architecture to speed
data transfers.
Also, the on-chip Flash can be
accessed in a single cycle, achieving
the best possible performance
per MHz

any way don’t use an old trick if your mcu is dspic its doesn’t work
and mikroC don’t have directive for allocation rom during compilation time
but like CCS  compiler
#rom  0x200={1,2,3,45}

 flash_write function working fine for update your data in flash memory and flash_read function also working well for retrieve data    belong to this exam:

Code:
unsigned int iArr[64] = {'m', 'i', 'k', 'r', 'o', 'E', 'l', 'e', 'k', 't', 'r', 'o', 'n', 'i', 'k', 'a'};
char cArr[] = "supercalifragillisticexpialidotiousABCDEFGHIJKLMNOPRSTUVWXYZ1234";
char cArr2[64];

void * pv1;

void main() {
  unsigned i, k;

  AD1PCFG = 0xFFFF;
  PORTB = 0x0004;
  TRISB = 1;
 
  for(i=16;i<64;i++)
    iArr[i] = 'x';
 
  for(i=64;i<192;i++)
    cArr[i] = 'y';
 

  // press RB0 to continue
  while (!PORTB.f0)
    ;
   
  //--- erase the block first
  Flash_Erase(0x006400);

  //--- now for some non-compact flash-write
  pv1 = iArr;
  Flash_Write(0x006500, pv1);

  PORTB = 0x0008;

  //--- write compact format to flash
  pv1 = cArr;
  Flash_Write_Compact(0x006400, pv1);

  PORTB = 0x0010;

  //--- read compact format
  pv1 = cArr2;
  Flash_Read_Compact(0x006400, pv1, 64);
  pv1[64] = 0;  //termination

  //--- show what has been written
  i = 0;
  Uart1_Init(9600);
  Uart1_Write_Char('s'); Uart1_Write_Char('t'); Uart1_Write_Char('a'); Uart1_Write_Char('r');
  Uart1_Write_Char('t'); Uart1_Write_Char(10);
  while(cArr2[i])
    Uart1_Write_Char(cArr2[i++]);

  PORTB = 0x0018;

}//~!

regards Eng amar


Logged
tzehon
V.I.P
Newbie
*****
Offline Offline

Posts: 11

Thank You
-Given: 2
-Receive: 1


« Reply #6 on: November 30, 2009, 05:39:45 17:39 »

Hi,

Thanks for the reply.

Code:
Flash_Erase(0x006400);
and
Flash_Write(0x006500, pv1);

May i know can the 0x006400 and  0x006500 replace by pointer (with offset) to make the code more dynamic ?
i am using dspic30f4011, do Flash_Erase32 and Flash_Write_Block make any difference ?
And can i initialize something on the ROM instead of write into it and read from it again?

Thanks again for the help.

tzehon
« Last Edit: November 30, 2009, 06:02:53 18:02 by tzehon » Logged
msamar
Newbie
*
 Muted
Offline Offline

Posts: 28

Thank You
-Given: 0
-Receive: 4


« Reply #7 on: December 01, 2009, 07:35:54 07:35 »

HelloYes you can use pointers instead of direct address
as ex
Code:
unsigned long addr[] = {0x006400,0x006500};
unsigned long* ptrAdr = addr;
Flash_Erase(*ptrAdr);
Also I see you should read an mikroC help documents like

Flash Memory Library
This library provides routines for accessing microcontroller's (internal) Flash memory.
On the dsPIC30/33 and PIC24, Flash memory is mapped to address space 3:2, which means that every 3 consecutive bytes of Flash have 2 consecutive address locations available. That is why mikroE's library allows data to be written to flash in two ways: "regular" and "compact". In the "regular" mode, which is used for word(16-bit) variables, the 3rd (un-addressable) flash memory byte remains unused. In the "compact" mode, which can be used for 1 byte-sized variables/arrays, all flash bytes are being used.
All dsPIC30/33 and PIC24 MCUs use the RTSP module to perform Read/Erase/Write operations on Flash memory. This, together with the internal structure of the Flash, imposes certain rules to be followed when working with Flash memory:
dsPIC30:
•   Erasing can be done only in 32-instructions (64 addresses, 96 bytes) memory blocks. This means that the block start address should be a multiply of 64 (i.e. have 6 lower bits set to zero).
•   Data is read and written in 4-instructions (8 addresses, 12 bytes) blocks.This means that the block start address should be a multiply of 8 (i.e. have 3 lower bits set to zero).
•   On the dsPIC30s, 2 address locations are assigned on every 3 bytes of (flash) program memory. Due to this specific and non-one-to-one address mapping, the mikroC offers two sets of Flash handling functions: "regular" and "compact".
Using the "regular" set, the user can write one byte of data to a single address, which means that each byte of written data has its own address, but on every 2 written bytes one byte of Flash memory remains empty.
Using the "compact" set, every byte of Flash memory, including those non-addressable, is filled with data; this method can only be used for data organized in bytes.
The "compact" functions have _Compact as name suffix.
•   For run-time FLASH read/write, the dsPIC30's RTSP module is being used. It organizes data into rows and panels. Each row contains write latches that can hold 4 instructions (12 bytes). The number of panels varies from one dsPIC30 MCU model to another. Because of that, the flash write sequence has been split into several operations (_Write_Init(), _Write_LoadLatch4(), _Write_DoWrite()), in order to be usable on all dsPICs.
PIC24 and dsPIC33:
•   Erasing can be done only in 512-instructions (1024 addresses, 1536 bytes) memory blocks, which means that the block start address should be a multiply of 1024 (i.e. have 10 lower bits set to zero).
•   Data is read and written in 64-instructions (128 addresses, 192 bytes) blocks.This means that the block start address should be a multiply of 128 (i.e. have 7 lower bits set to zero).
•   On the dsPIC33 and PIC24s, 2 address locations are assigned on every 3 bytes of (flash) program memory. Due to this specific and non-one-to-one address mapping, the mikroC offers two sets of Flash handling functions: "regular" and "compact".
Using the "regular" set, the user can write one byte of data to a single address, which means that each byte of written data has its own address, but on every 2 written bytes one byte of Flash memory remains empty.
Using the "compact" set, every byte of Flash memory, including those non-addressable, is filled with data; this method can only be used for data organized in bytes.
The "compact" functions have _Compact as name suffix.


Also if you need ( read only) data storing on the flash memory ,
And because mikroC don’t supported like CCS you can edit your hex file by any dspic programmer like  
WinPic800 prog visit www.winpic800.com
Go to address like 0x06400 write your data starting this address then store hex file and burn your mcu using this one ,
Before that your data read should  be managed by your program software , ok it is just an idea instead of waiting mikroC team to update there directives next 50 years!

Regards Eng amar
 
 
 

« Last Edit: December 01, 2009, 07:55:16 07:55 by msamar » Logged
tzehon
V.I.P
Newbie
*****
Offline Offline

Posts: 11

Thank You
-Given: 2
-Receive: 1


« Reply #8 on: December 01, 2009, 06:05:50 18:05 »

Hi,

Thanks amar for  providing so much help. I think finally i understand how this library going. Thank you.
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC