PSOC4 - firmware freezes trying to write to user row FLASH

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
DaGa_4378306
Level 4
Level 4
10 replies posted 5 replies posted 5 questions asked

Hi

I'm trying to write some data into a user row, but the PSOC4 device just freezes at that function that writes to the user-row. The debugger just stops at the function call, and you cannot put breakpoints inside the function.   The IMO is enabled and at 48 MHz as well.

Any other ideas why this function won't work?

void controller_testfun(uint8_t* data, uint8_t num_data) {

   

    uint32_t code;

    uint32_t row = 0;

    uint8_t write_data[CY_SFLASH_SIZEOF_USERROW];

   

    // Fill the full row

    memcpy(&write_data[0], data, num_data*sizeof(uint8_t));

    for (uint8_t loop1 = num_data; loop1 < CY_SFLASH_SIZEOF_USERROW; loop1++) {

        write_data[loop1] = 0;  

    }

    code = CySysSFlashWriteUserRow(row, write_data);

    if (code != CY_SYS_SFLASH_SUCCESS) {

        code = CySysSFlashWriteUserRow(row, write_data);

    }

}

0 Likes
1 Solution
DaGa_4378306
Level 4
Level 4
10 replies posted 5 replies posted 5 questions asked

Okay, so I've been debugging for awhile now, but the minute I posted to the forums, I figured it out!

CY_SFLASH_SIZEOF_USERROW is actually 256 bytes for my device, so using the uint8_t for the loop variable and size leads to the infinite loop!

void controller_testfun(uint8_t* data, uint16_t num_data) {

  

    uint32_t code;

    uint32_t row = 0;

    uint8_t write_data[CY_SFLASH_SIZEOF_USERROW];

  

    // Fill the full row

    memcpy(&write_data[0], data, num_data*sizeof(uint8_t));

    for (uint16_t loop1 = num_data; loop1 < CY_SFLASH_SIZEOF_USERROW; loop1++) {

        write_data[loop1] = 0; 

    }

    code = CySysSFlashWriteUserRow(row, write_data);

    if (code != CY_SYS_SFLASH_SUCCESS) {

        code = CySysSFlashWriteUserRow(row, write_data);

    }

}

View solution in original post

0 Likes
1 Reply
DaGa_4378306
Level 4
Level 4
10 replies posted 5 replies posted 5 questions asked

Okay, so I've been debugging for awhile now, but the minute I posted to the forums, I figured it out!

CY_SFLASH_SIZEOF_USERROW is actually 256 bytes for my device, so using the uint8_t for the loop variable and size leads to the infinite loop!

void controller_testfun(uint8_t* data, uint16_t num_data) {

  

    uint32_t code;

    uint32_t row = 0;

    uint8_t write_data[CY_SFLASH_SIZEOF_USERROW];

  

    // Fill the full row

    memcpy(&write_data[0], data, num_data*sizeof(uint8_t));

    for (uint16_t loop1 = num_data; loop1 < CY_SFLASH_SIZEOF_USERROW; loop1++) {

        write_data[loop1] = 0; 

    }

    code = CySysSFlashWriteUserRow(row, write_data);

    if (code != CY_SYS_SFLASH_SUCCESS) {

        code = CySysSFlashWriteUserRow(row, write_data);

    }

}

0 Likes