Question about Flash Memory Library

General discussion on mikroC for dsPIC30/33 and PIC24.
Post Reply
Author
Message
Berkl
Posts: 124
Joined: 05 May 2009 13:09
Location: Russia
Contact:

Question about Flash Memory Library

#1 Post by Berkl » 02 Sep 2009 20:33

Hello friends

I'm working with the Flash_Test.dpc test project

Compiler: MikroC for dsPIC 4.0.0.0
Board: lv24-33A
CPU: PIC24FJ96GA010

I downloaded this project (without changes in code) to the board and scope to the Communication Terminal tool in HEX mode (not ASCII).
I saw the follows:
Connected to COM1
Received: 0x73 0x74 0x61 0x72 0x74 0x0A 0x73 0x75
Received: 0x70 0x65 0x72 0x63 0x61 0x6C 0x69 0x66
Received: 0x72 0x61 0x67 0x69 0x6C 0x6C 0x69 0x73 0x74 0x69 0x63 0x65 0x78 0x70 0x69 0x61
Received: 0x6C 0x69 0x64 0x6F 0x74 0x69 0x6F 0x75
Received: 0x73 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4A 0x4B 0x4C 0x4D 0x4E 0x4F
Received: 0x50 0x52 0x53 0x54 0x55 0x56 0x57 0x58
Received: 0x59 0x5A 0x31 0x32 0x33 0x34

That is good.

The next, I wanted to be sure, about all OK. So, I just commented the part of the code with Erase/Write built-in flash functions:

......

// 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);

//--- write compact format to flash
pv1 = cArr;
Flash_Write_Compact(0x006400, pv1);
*/
//--- read compact format
pv1 = cArr2;
Flash_Read_Compact(0x006400, pv1, 64);


......

The next, again: Compiling-->Downlading-->Scope in Communication Terminal tool.

I was expect to see the same result as before in Communication Terminal tool after I did these code changes, but...

I got the follows:

Connected to COM1
Received: 0x73 0x74 0x61 0x72 0x74 0x0A 0xFF 0xFF
Received: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
Received: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
Received: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
Received: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
Received: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

That is not good.

Therefore, I guess, the built-in Flash_Write_Compact function (as well as Flash_Write function) works not correctly.

Is it truth or wrong?


Thank you for your answer,

have a nice day.

User avatar
nikola.kostic
mikroElektronika team
Posts: 433
Joined: 11 Aug 2009 12:12

#2 Post by nikola.kostic » 04 Sep 2009 09:44

Result you got after commenting mentioned part of the example code is expected. When you program chip flash is erased, therefore you should get 0xFFs with your modified code which is exactly what you got.

0x73, 0x74, 0x61 and so on are s, t and a respectively and so on and they are written in your terminal by Uart1_Write commands that you haven't commented.

Berkl
Posts: 124
Joined: 05 May 2009 13:09
Location: Russia
Contact:

#3 Post by Berkl » 04 Sep 2009 11:28

Thank you Nikola

In fact, it's very simple

Post Reply

Return to “mikroC for dsPIC30/33 and PIC24 General”