Personal tools
You are here: Home Forums R8C/Tiny Use Data Flash

Use Data Flash

Up to R8C/Tiny

Use Data Flash

Posted by gregory marboeuf at July 28. 2008

Hi,

I work on a R8C13. I want to implement code in order to use data flash. I find file to help me in erase and program data flash, but when I add it in my program, it make "ILLEGAL INSTRUCTION". I think it's probably about the sect30.inc file, I don't know how must it be modify to use dataflash memory.

For information, I work with HEW and E8.

Thank's

Re: Use Data Flash

Posted by FrankL at July 28. 2008

Could you give some more details on the error message?

Is it an assembler message, compiler message, linker message?

Can you give the complete error message, including the instruction which is not understood?

Did you try to use one of the examples in this forum (e.g. http://www.renesasrulz.com/downloads/r8c-tiny/simple_data_flash.zip/view)?


Re: Use Data Flash

Posted by gregory marboeuf at July 28. 2008

This message appear on Debug windows.

I implement the simple data flash find on this forum. I add functions to my own program (it work when I do no call the erase function).

I lauch program, it make nothing during about 4 second and after it display on debug windows:

E8 firmware version "1.16.00.000"

Connected

Flash memory writing ...

Flash memory write end

RESET CPU

ILLEGAL INSTRUCTION

I don't know where is the bug, after that, the pointer reset.

Re: Use Data Flash

Posted by FrankL at July 28. 2008

Does the source window display valid code after RESET? Please check in mixed mode display or in disassembler view.

What do you do after Reset? Push GO/Single Step?

Re: Use Data Flash

Posted by gregory marboeuf at July 28. 2008

Thank you for your held Frank,

This is the HEW state after about 5 second I reset and go the program:

- Debug windows display "ILLEGAL INSTRUCTION"

- On main windows, HEW display the *.a30 file, at this point: " ldc #istack_top, isp ;set istack pointer"

- After that, when I press ResetGo button, the same comportement appear

Re: Use Data Flash

Posted by FrankL at July 28. 2008

Your software jumps to an illegal address outside your application. Then reads an instruction which it cannot understand.

Please tell the linker to generate a map file and check this map file.

Are the section istack and stack initialised and at valid addresses?

Which addresses uses the section program?

Re: Use Data Flash

Posted by gregory marboeuf at July 28. 2008

Also I use the E8 debugger, so this is it a problem?

This is the section program, it is the original copie of the demonstration program supplie with R8C13 demoboard:

;---------------------------------------------------------------
; Near RAM data area
;---------------------------------------------------------------
; SBDATA area
 .section data_SE,DATA
 .org 400H
data_SE_top:

 .section bss_SE,DATA,ALIGN
bss_SE_top:

 .section data_SO,DATA
data_SO_top:

 .section bss_SO,DATA
bss_SO_top:

; near RAM area
 .section data_NE,DATA,ALIGN
data_NE_top:

 .section bss_NE,DATA,ALIGN
bss_NE_top:

 .section data_NO,DATA
data_NO_top:

 .section bss_NO,DATA
bss_NO_top:

;---------------------------------------------------------------
; Stack area
;---------------------------------------------------------------
 .section stack,DATA,ALIGN
 .blkb STACKSIZE
stack_top:

 .blkb ISTACKSIZE
istack_top:

;---------------------------------------------------------------
; heap section
;---------------------------------------------------------------
 .section heap,DATA
heap_top:
 .blkb HEAPSIZE

;---------------------------------------------------------------
; Near ROM data area
;---------------------------------------------------------------
 .section rom_NE,ROMDATA
 .org  0e000H  
rom_NE_top:

 .section rom_NO,ROMDATA
rom_NO_top:

;---------------------------------------------------------------
; Initial data of 'data' section
;---------------------------------------------------------------
 .section data_SEI,ROMDATA,ALIGN
data_SEI_top:

 .section data_SOI,ROMDATA
data_SOI_top:

 .section data_NEI,ROMDATA,ALIGN
data_NEI_top:
 
 .section data_NOI,ROMDATA
data_NOI_top:

;---------------------------------------------------------------
; Switch Table Section
;---------------------------------------------------------------
 .section        switch_table,ROMDATA
switch_table_top:

;---------------------------------------------------------------
; code area
;---------------------------------------------------------------

 .section program,CODE,ALIGN

 .section interrupt,CODE,ALIGN

Re: Use Data Flash

Posted by FrankL at July 28. 2008

If you don't use stdio and your software does not use UART1 this is usually no problem. And if it were a problem you would usually get a communication error as error message, not illegal instruction.

Your sect30 looks fine. But this does not say anything which address ranges are used. To see this you have to check the map file.

Re: Use Data Flash

Posted by gregory marboeuf at July 28. 2008

Ok Frank, I didn't understand that you needed. I just find how display the *.map file and it give:

data_NE: 0400 to 0445

bss_NE: 0446 to 044F

data_NO: 0450 to 0450

stack: 0425 to 0551

data_NEI: E000 to E045

data_NOI: E046 to E046

program: E048 to E4F5

interrupt: E4F6 to E598

Other information: I do not use stdio, and do not use UART1.

vector: FEDC to FFDB

fvector: FFFC to FFFF

Re: Use Data Flash

Posted by Calvin Grier at July 28. 2008

Did HEW generate the project for you? Or did you cut and paste and example from a CD? In North America, the R8C/13 kits came with a HEW project generator for a "VirtualEE" project. Is that the one you are using?

You may be able to generate a new workspace in HEW that wil build the VirtualEE in a new folder for you. It should run.

Re: Use Data Flash

Posted by gregory marboeuf at July 28. 2008

As it's first development with R8C13, I take the RSK demoboard project and just modify the main program (and sect30.inc for enable interrupt).

So I will test to generate a totaly new project with HEW (trying to find "Virtual EE", because I never look for it). Thank's

Re: Use Data Flash

Posted by FrankL at July 29. 2008

Could it be that you either did not put #pragma INTERRUPT interrupt_function_name, or that you included your interrupt vector in the wrong interrupt table? Older sect30.inc (and ncrt0.a30) files do have one part for M16C and one for R8C. Its quite easy to modify data in the section not used by the actual processor.

Re: Use Data Flash

Posted by gregory marboeuf at July 29. 2008

I check interrupt use, I see no problem (when I don't call "memory" function, the program work).

However how can I check if I use the good interrupt table (I also preserve the orginal sect30.inc, but just add ".glb _TIMER_X_INT" and " .lword _TIMER_X_INT ; vector 22  //_TIMER_X_INT timer pour mesure régime" on each interrupt I needed).

I try also to put the firmware in BLOCKA then BLOCKB then 0C000h, but the error also present.

Re: Use Data Flash

Posted by FrankL at July 29. 2008

The SimpleData Flash example has a bug. At the end of EraseBlock and WriteBlock it should NOT be "fmr0 = 0;", but it should be "fmr01 = 0;" to clear only the EW mode bit.

THE CORRECT CODE IS "fmr01 = 0;"

Re: Use Data Flash

Posted by gregory marboeuf at July 29. 2008

I replace by "fmr01 = 0", and it works!
I sincerely thank you for your reactivity and for the time you passed to help me.

Re: Use Data Flash

Posted by gregory marboeuf at August 14. 2008

I want an advise about this function, used for read data flash memory after the device power on.

Is it an efficient method for read memory? Does I have to add anything to securize this function?

void lectureMemoire(void)

{

unsigned char * adresseALire;

int m = 0;

adresseALire = &(unsigned char)BLOCK_A;

for(m = 0; m<16; m++)

     {

     ramTampon[m] = adresseALire[m];

     }

}

Re: Use Data Flash

Posted by Calvin Grier at August 19. 2008

Data flash can be addressed just like any other memory for reading. I don't see the #define for BLOCK_A. Does this code run?

You might want to try creating a structure with the array of bytes and just assigning the pointer to a structure the address of BLOCK_A.

Re: Use Data Flash

Posted by gregory marboeuf at August 21. 2008

Yes, this code run, I defined BLOCK_A in *.h file.

I will try to make strcuture for futur developpement that use recursive type of data to memorise.

Powered by Ploneboard