PSOC4 Reading of flash

A catchall for PSoC Mixed-Signal Array (microcontroller) discussions not captured by the other forums.

Moderator: ericb

PSOC4 Reading of flash

Postby dmi » Wed Feb 19, 2014 4:10 am

Hi,

I've tried to read the flash memory of PSOC4 Cortex-M0, but I haven't successful (I've always read the RAM - using const char* pointer). There's lots of code about writing to that via bootloader, but I haven't found the reading method. Is there any simple way to realize that?

Thanks you
dmi
Newbie
Newbie
 
Posts: 4
Joined: Wed Feb 19, 2014 4:03 am

Re: PSOC4 Reading of flash

Postby bobmarlowe » Wed Feb 19, 2014 7:35 am

You have to define some variables in flash and assign a value to them. The "const" attribute will do.
Accessing the variable is done easily as long as it is used as a "right-side term" meaning nothing is assigned to that var again.
Alternatively you may define a pointer to which you assign the required read-address.

Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: PSOC4 Reading of flash

Postby dmi » Wed Feb 19, 2014 12:00 pm

It's OK, but I need read full flash, started at 0x00000000.

I've tried this code:

Code: Select all
int main(void)
{
    uint32_t array[5];
    uint8_t i;
    const uint32_t *ptr;
   
    ptr = 0x00;
   
    for(i = 0; i < 5; i++)
    {
        array[i] = *ptr;
        ptr++;
    }
   
    return 0;
}


The result is filling array variable by SRAM bytes instead of FLASH bytes.
dmi
Newbie
Newbie
 
Posts: 4
Joined: Wed Feb 19, 2014 4:03 am

Re: PSOC4 Reading of flash

Postby bobmarlowe » Wed Feb 19, 2014 12:46 pm

Double check that, I am reading from flash address 0. Compare that in debugger it is starting with 20002000 and is the initial stackpointer value.
You may leave the "const" here, since you provide the pointer's value yourself.

Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: PSOC4 Reading of flash

Postby dmi » Wed Feb 19, 2014 10:44 pm

I have PSoc Creator 3.0 Componenet Pack 7 and CY8C8485LQI 483. Can you send me your project ? I would like to compare the project settings and another stuff. Watch window show right value in *ptr, but after the coping to array variable, data is wrong.

Thanks
dmi
Newbie
Newbie
 
Posts: 4
Joined: Wed Feb 19, 2014 4:03 am

Re: PSOC4 Reading of flash

Postby bobmarlowe » Thu Feb 20, 2014 2:42 am

This is simply your project running on a PSoC4 (I also tried a PSoC5).

ReadFlash.jpg


Project in next post

Bob
Last edited by bobmarlowe on Thu Feb 20, 2014 2:45 am, edited 1 time in total.
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: PSOC4 Reading of flash

Postby bobmarlowe » Thu Feb 20, 2014 2:43 am

Project archieve attached.


Bob
Attachments
ReadFlash.cywrk.Archive01.zip
(13.53 KiB) Downloaded 248 times
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: PSOC4 Reading of flash

Postby dmi » Thu Feb 20, 2014 3:45 am

Now, when I open output HEX in notepad, result is:

:40 0000 00 0010002011000000A1020000A1020...

We have same result - this data are from SRAM memory 0x20000000. First bytes are same, there is different in 5. byte...
dmi
Newbie
Newbie
 
Posts: 4
Joined: Wed Feb 19, 2014 4:03 am

Re: PSOC4 Reading of flash

Postby bobmarlowe » Thu Feb 20, 2014 5:55 am

You are probably looking at the array which resides in sram. Take it for granted: a pointer addresses exactly what you let it point to. ARM Cortex do not make any differences between memory areas like the 8051 core in PSoC3. Have a look at the PSoC5 memory map in this document


Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany


Return to “%s” PSoC1 General

Who is online

Users browsing this forum: Bing [Bot] and 2 guests