How to program flash with PSoC 4100S Plus(CYPRESS)?

0

I am using the PSoC 4100S Plus (CYPRESS) chip.I want to operate the chip through SWD.

Here has Official documents enter link description here

And i also found some example on github enter link description here

I can successfully read the SWD ID, Silicon ID and Erases all the user's flash,but program the flash and read the flash is different.I think it didn't program int the flash,is there have any method? I don't have any idea,thanks a lot.here is my read flah & program flash code

/read flash/

    for (i = 0; i < BYTES_PER_FLASH_ROW; i += 4) {
        /* Read flash via AHB-interface */
        //Read_IO(SRAM_PARAMS_BASE + i + 0x08, &flashData);
        Read_IO(rowAddress + i, &flashData);
        if (swd_PacketAck != SWD_OK_ACK) {
            return (FAILURE);
        }

        chipData[i + 0] = (flashData >> 0) & 0xFF;
        chipData[i + 1] = (flashData >> 8) & 0xFF;
        chipData[i + 2] = (flashData >> 16) & 0xFF;
        chipData[i + 3] = (flashData >> 24) & 0xFF;
    }

/program flash/

for (i = 0; i < BYTES_PER_FLASH_ROW; i += 4) {
    parameter1 =
        (rowData[i] << 0) + (rowData[i + 1] << 8) +
        (rowData[i + 2] << 16) + (rowData[i + 3] << 24);

    /* Write parameter1 in SRAM */
    Write_IO(SRAM_PARAMS_BASE + 0x08 + i, parameter1);
    Write_IO(TEST_MODE , parameter1);

}

Write_IO(CPUSS_SYSARG, SRAM_PARAMS_BASE);

    /* Request SROM operation */
Write_IO(CPUSS_SYSREQ, SROM_SYSREQ_BIT | SROM_CMD_LOAD_LATCH);

parameter1 = (uint32_t) (((uint32_t) SROM_KEY1 << 0) +
                (((uint32_t) SROM_KEY2 +
                  (uint32_t) SROM_CMD_PROGRAM_ROW) << 8) +
                (((uint32_t) arrayID & 0x000000FF) << 16) +
                (((uint32_t) arrayID & 0x0000FF00) << 16));

Write_IO (SRAM_PARAMS_BASE+0x00, parameter1); // Write params in SRAM

Write_IO (CPUSS_SYSARG, SRAM_PARAMS_BASE); // Set location of parameters

Write_IO (CPUSS_SYSREQ, SROM_SYSREQ_BIT | SROM_CMD_PROGRAM_ROW); // SROM operation
c
swd
asked on Stack Overflow Oct 25, 2019 by 邱奕愷

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0