Announcements
IMPORTANT: Cypress Developer Community is transitioning on October 20th. To learn more and be prepared for this change, check out our latest announcement.
cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC Creator & Designer Software

ReMa_3807036
New Contributor II

Hi,

I'm using PSoC Creator 4.3 with device PSOC4100S  CY8C4125AXI-S433, in my design I'm using Flash to emulate EEprom and I'm following the relative code example, and here I have a problem, the variable "Em_EEPROM_em_EepromStorage" within the generated file Em_EEPROM.c, is declarated only if defined "CY_PSOC6", and it is not here the case.

#if ((CY_PSOC6) && (Em_EEPROM_1_STORAGE_EM_EEPROM))

    CY_SECTION(".cy_em_eeprom") CY_ALIGN(CY_FLASH_SIZEOF_ROW)

    const uint8 Em_EEPROM_1_em_EepromStorage[Em_EEPROM_1_ACTUAL_SIZE] = {0u};

#endif /* ((CY_PSOC6) && (Em_EEPROM_1_STORAGE_EM_EEPROM)) */

Probably I'm wrong ... Have you any suggestions?

Thanks

Renato

0 Likes
1 Solution
MotooTanaka
Esteemed Contributor

Dear Renato-san,

Please READ the datasheet of Em_EEPROM.

In the page 2 it is written

002-Datasheet-Page2.JPG

Please read carefully after the line "For non-PSoC 6 devices,.."

Best Regards,

19-May-2020

moto

View solution in original post

0 Likes
6 Replies
MotooTanaka
Esteemed Contributor

Hi,

I just tried generate a similar project and in the Em_EEPROM.c

in the comment of Em_EEPROM_Int, it is written.

=====================

* Fills the start address of the EEPROM to the component configuration structure

* and invokes Cy_Em_EEPROM_Init() function. In case of PSoC 6 the function

* is located in Cy_Em_EEPROM middleware library which is part of PDL. In case if

* it is utilized in the design based on non-PSOC 6 device the function is

* located in internal design wide resource component - Em_EEPROM_Dynamic.

=====================

So, I think that even if you are not using PSoC 6, Em_EEPROM will work with your project.

Have you built and tried the project?

moto

0 Likes
ReMa_3807036
New Contributor II

Thanks Moto, but I have not solved...

Yes I have built the project (not yet tried), it shows the following error:

Build error: undefined reference to `Em_EEPROM_1_em_EepromStorage'

(please note that my module name is Em_EEPROM_1)

Really this error is correct because the 'Em_EEPROM_1_em_EepromStorage' is not declared,

In Em_EEPROM_1.c file it is conditioned by CY_PSOC6 define, but I'm not using PSOC6 but PSOC4, so it is false.

#if ((CY_PSOC6) && (Em_EEPROM_1_STORAGE_EM_EEPROM))

    CY_SECTION(".cy_em_eeprom") CY_ALIGN(CY_FLASH_SIZEOF_ROW)

    const uint8 Em_EEPROM_1_em_EepromStorage[Em_EEPROM_1_ACTUAL_SIZE] = {0u};

#endif /* ((CY_PSOC6) && (Em_EEPROM_1_STORAGE_EM_EEPROM)) */

Really if I force that declaration i.e. with

CY_SECTION(".cy_em_eeprom") CY_ALIGN(CY_FLASH_SIZEOF_ROW)

    const uint8 Em_EEPROM_1_em_EepromStorage[Em_EEPROM_1_ACTUAL_SIZE] = {0u};

the ERROR disappear (then I do not know it work ).

In any case, I prefer to avoid any forcing... the automatic code generation should work!

I'm following the code example "CE195313 – PSoC Emulated EEPROM".

0 Likes
MotooTanaka
Esteemed Contributor

Hi,

I found a sample I (?) wrote a while ago.

It was for fixed address Em_EEPROM, but I modified it to be without linker script.

Then I changed the device to CY8C4146LQI-S433, (TSoC) as it is the only 4100S I have.

schematic

001-schematic.JPG

Tera Term Out

tera_term_log.JPG

main.c

=============

#include "project.h"

#include "stdio.h"

static const uint8_t store[Em_EEPROM_PHYSICAL_SIZE]

__ALIGNED(CY_FLASH_SIZEOF_ROW) = { 0u } ;

cy_en_em_eeprom_status_t status ;

char str[128] ; /* print buffer */

void print(char *str)

{

    UART_UartPutString(str) ;

}

void print_em_eprom_error(cy_en_em_eeprom_status_t status)

{

    switch(status) {

    case CY_EM_EEPROM_SUCCESS:      print("No Error\n") ; break ;

    case CY_EM_EEPROM_BAD_PARAM:    print("The input parameter is invalid\n") ; break ;

    case CY_EM_EEPROM_BAD_CHECKSUM: print("The data in EEPROM is correupted\n") ; break ;

    case CY_EM_EEPROM_BAD_DATA:     print("Failed to place the EEPROM in flash\n") ; break ;

    case CY_EM_EEPROM_WRITE_FAIL:   print("Write to EEPROM failed\n") ; break ;

    default:

        sprintf(str, "EEPROM Unknown Error %d\n", status) ;

        print(str) ;

        break ;

    }

}

void init_hardware(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */

    UART_Start() ;

   

    status = Em_EEPROM_Init((uint32_t)store) ;

    if (status != CY_EM_EEPROM_SUCCESS) {

        print_em_eprom_error(status) ;

    }

}

void splash(void)

{

    sprintf(str, "Emulated EEPROM Test (%s %s)\n", __DATE__, __TIME__) ;

    print(str) ;

}

int main(void)

{

    unsigned int i ;

    unsigned int test_size = 16 ;

   

    uint8 zustand[Em_EEPROM_EEPROM_SIZE] = {} ;

    init_hardware() ;

   

    splash() ;

   

    sprintf(str, "EEPROM SIZE = %d\n", Em_EEPROM_EEPROM_SIZE) ;

    print(str) ;

   

    print("Store:\n") ;

    for (i = 0 ; i < test_size * 2 ; i++ ) {

        sprintf(str, "%02X ", store) ;

        print(str) ;

        if (i == 0xF) {

            print("\n") ;

        }

    }

    print("\n") ;

    print("Values to be written:\n") ;

    for (i = 0 ; i < test_size ; i++) {

        zustand = 0xF0 + i ;

        sprintf(str, "%02X ", zustand) ;

        print(str) ;

    }

    print("\n") ;

   

    CyDelay(10) ;

   

    status = Em_EEPROM_Write((uint32)0, (void*)zustand, test_size) ;

    if (status != CY_EM_EEPROM_SUCCESS) {

        print_em_eprom_error(status) ;

    }

   

   

    print("Store:\n") ;

    for (i = 0 ; i < test_size * 2 ; i++ ) {

        sprintf(str, "%02X ", store) ;

        print(str) ;

        if (i == 0xF) {

            print("\n") ;

        }

    }

    print("\n") ;

       

    for (i = 0 ; i < test_size ; i++ ) {

        zustand = 0 ;

    }

   

    status = Em_EEPROM_Read((uint32)0, zustand, test_size) ;

    if (status != CY_EM_EEPROM_SUCCESS) {

        print_em_eprom_error(status) ;

    }

   

    print("Values read:\n") ;

    for (i = 0 ; i < test_size ; i++ ) {

        sprintf(str, "%02X ", zustand) ;

        print(str) ;

    }

    print("\n") ;

    for(;;)

    {

        /* Place your application code here. */

    }

}

=============

Attached is the project with device target changed to CY8C4125AXI-S433.

I was compile-able, but I have not tested it on the real device.

moto

0 Likes
ReMa_3807036
New Contributor II

Hi Moto,

thanks for your answer.

I will follow your example, even if you go over the problem because in main.c you declare   "store" (then used in Em_EEPROM_Init(..) function)

static const uint8_t store[Em_EEPROM_PHYSICAL_SIZE]

instead to use "Em_EEPROM_em_EepromStorage" as in the code example within PSoc Creator 4.3, it is declared also in your example at line 40 of Em_EEPROM.c file, but it is not reachable ... (as already written).

Best Regards

Renato

0 Likes
MotooTanaka
Esteemed Contributor

Dear Renato-san,

Please READ the datasheet of Em_EEPROM.

In the page 2 it is written

002-Datasheet-Page2.JPG

Please read carefully after the line "For non-PSoC 6 devices,.."

Best Regards,

19-May-2020

moto

View solution in original post

0 Likes
ShVy_264716
New Contributor II

Hi ReMa_3807036

I have gone through the datasheet of Emulated EEPROM and I have followed all the steps listed to set up location based EEPROM in my PSoC4. While editing the linker script file "cm0gcc.ld" copy (custom_cm0gcc.ld), the key point is finding the line

.cy_checksum_exclude : { KEEP(*(.cy_checksum_exclude)) } >rom

in the code and adding the code segment

EM_EEPROM_START_ADDRESS = <EEPROM Address>;

.my_emulated_eeprom EM_EEPROM_START_ADDRESS :

{

KEEP(*(.my_emulated_eeprom))

} >rom

below it. I can not find the line in the linker file anywhere. What can be the reason behind this? Attached herewith is my project and linker file.

Regards

Shaunak Vyas

0 Likes