Cypress技术论坛
直播中

王建华

7年用户 350经验值
私信 关注
[问答]

为什么函数SPSPIFLASHSTATE两次读取TH SPI闪存模块的状态?

你好,
为什么函数SPSPIFLASHSTATE两次读取TH SPI闪存模块的状态?
DO while循环结束时的检查只比较第一个接收到的关于忙和WIP标志的字节。也是M25P40数据表告诉不需要阅读现状两次在指令集的描述。
但我确定的是,结果错写的如果我只是曾经的地方阅读的现状。
有人能解释一下我的行为吗?
谢谢,
隆皮

以上来自于百度翻译


     以下为原文
   Hi,
    why is the function GetSpiFlashStatus reading the status of th SPI flash module twice?
    The checks at the end of the do while loop just compare the first received byte concerning on BUSY and WIP flags. Also the datasheet of the M25P40 is telling no need to read the status twice at the instruction set description.
    But what I have identified is, that it results in wrong writes if I read the status at that place just once.
    Can anybody explain me that behaviour, please?
    thanks,
    Lumpi

回帖(7)

h1654155275.5814

2019-1-30 12:20:08
嗨,Lumpi,
你在u***flashprog工程实例谈cyfxflashprogspiwaitforstatus功能?.
请让我知道。
谢谢,
西克里希纳。

以上来自于百度翻译


     以下为原文
  Hi Lumpi,
    Are you talking about CyFxFlashProgSpiWaitForStatus function in USBFlashProg example project?.
    Please let me know.
    Thanks,
    sai krishna.
举报

王建华

2019-1-30 12:39:01
嗨,Sai Krishna,
这个函数,但它总是在项目中相同的功能:
CyfxFlash Pro
青霉
- CyfxSubSigigoMo.c
- CyfxSbbRigReal.c
CyfXAc
*等待来自SPI闪存的状态响应。*/Cyu3PrEntStutsUst CyfxSmithWistFoStand(空隙){UIT88T BUF〔2〕,RDYBUF〔2〕;CYU3PRESTROSTATUS SUT状态=CYU-U3PY成功;//等待来自SPI闪存装置的状态响应。*/do{Buf(0)=0x06;/*写使能命令。*/CYFXSPISETSnLIN(CyFLY);状态=CYFXSPITRAN SMITION(BUF,1);CyFxSpiSetSsnLine(Cytru.);IF(状态)!{Cyu3Upl成功){CyU3pDebug(2),“SPI WRIN使能命令失败\NR”);返回状态;}BUF(0)=0x05;/*读取状态命令*/CYFXSPISETSnLIN(CyFLY);状态=CYFXSPITRAN SMITION(BUF,1);如果(状态)!{Cyu3Upl成功){CYU3pDebug打印(2,“SPI Read Stand命令失败\NR”);CyFxSpiSetSsnLine(CyTrm);返回状态;}状态=CYFXSPIMPEVER词(RDYBUF,2);CyFxSpiSetSsnLine(Cytrut);IF(状态)!= cy_u3p_success){ cyu3pdebugprint(2,”SPI状态读取失败nn R”);} }而返回状态;((rd_buf [ 0 ] &;1)| |(!(RDYBUF〔0〕和0x2));返回CYU-U3PY成功;}
当做,
隆皮

以上来自于百度翻译


     以下为原文
  Hi Sai Krishna,
    e. g. this function but it is all the time the same function in Project:
    - cyfxflashprog.c
    - cyfxu***spidmamode.c
    - cyfxu***spigpiomode.c
    - cyfxu***spiregmode.c
    - cyfxuac.c
    /* Wait for the status response from the SPI flash. */
CyU3PReturnStatus_t
CyFxSpiWaitForStatus (
        void)
{
    uint8_t buf[2], rd_buf[2];
    CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

    /* Wait for status response from SPI flash device. */
    do
    {
        buf[0] = 0x06;  /* Write enable command. */

        CyFxSpiSetSsnLine (CyFalse);
        status = CyFxSpiTransmitWords (buf, 1);
        CyFxSpiSetSsnLine (CyTrue);
        if (status != CY_U3P_SUCCESS)
        {
            CyU3PDebugPrint (2, "SPI WR_ENABLE command failednr");
            return status;
        }

        buf[0] = 0x05;  /* Read status command */

        CyFxSpiSetSsnLine (CyFalse);
        status = CyFxSpiTransmitWords (buf, 1);
        if (status != CY_U3P_SUCCESS)
        {
            CyU3PDebugPrint (2, "SPI READ_STATUS command failednr");
            CyFxSpiSetSsnLine (CyTrue);
            return status;
        }

        status = CyFxSpiReceiveWords (rd_buf, 2);
        CyFxSpiSetSsnLine (CyTrue);
        if(status != CY_U3P_SUCCESS)
        {
            CyU3PDebugPrint (2, "SPI status read failednr");
            return status;
        }

    } while ((rd_buf[0] & 1)|| (!(rd_buf[0] & 0x2)));

    return CY_U3P_SUCCESS;
}

    regards,
    lumpi
举报

傅姁妮

2019-1-30 12:46:08
你好,
我修改了SpigReMead示例,只在WaIfFrand状态中读取了一个状态字节(我修改了读取状态命令,如下面粘贴的代码片段)。我能够从SPI闪光灯中成功地读写。我相信你已经意识到,对于SPI闪存来说,你需要用0xC2命令擦除SPI闪存。我希望你在写Flash之前做擦除。如果不是,请这样做。
BUF〔0〕=0x05;/*读取状态命令*/
CYU3PSPISETSSNLIN(CyFLUE);
状态= CYU3pSPITRANSITITENT(BUF,1);
如果(状态)!= CYU-U3PY成功
{
CYU3pDebug打印(2,“SPI Read Stand命令失败NR”);
CYU3PSPISETSSNLIN(Cyress);
返回状态;
}状态=CYU3PSPILIVE Word(RDYBUF,1);
CYU3PSPISETSSNLIN(Cyress);
如果(状态)!= CYU-U3PY成功
{
CYU3pDebug打印(2,“SPI状态读取失败\R”);
返回状态;
}
}((RDYBUF〔0〕和AMP;1)〕(!)(RDYBUF〔0〕和AMP;0x2));
当做,
加亚特里

以上来自于百度翻译


     以下为原文
   Hi,
     
    I modified the spiregmode example, and read only one status byte inside WaitforStatus (I modified the Read Status command as in the below pasted code snippet). I was able to succeffully read and write from the SPI flash. I believe you are aware of the fact that befor ewriting to SPI flash, you need to erase the SPI flash using 0xC2 command. I hope you are doing the erase before writing to the flash. If not please do so.
     
     
     buf[0] = 0x05;  /* Read status command */
    CyU3PSpiSetSsnLine (CyFalse);
    status = CyU3PSpiTransmitWords (buf, 1);
    if (status != CY_U3P_SUCCESS)
    {
                CyU3PDebugPrint (2, "SPI READ_STATUS command failednr");
                CyU3PSpiSetSsnLine (CyTrue);
                return status;
    }        
status = CyU3PSpiReceiveWords (rd_buf, 1);
    CyU3PSpiSetSsnLine (CyTrue);
    if(status != CY_U3P_SUCCESS)
    {
                CyU3PDebugPrint (2, "SPI status read failednr");
                return status;
    }
    } while ((rd_buf[0] & 1)|| (!(rd_buf[0] & 0x2)));
     
    Regards,
    Gayathri
举报

王建华

2019-1-30 13:05:35
你好,
我正在使用完全相同的代码,是的,我正在擦除Flash。我只是在写大量数据到Flash中遇到这个问题。2MB。然后大部分数据是正确的,但是一些小块被破坏了。
当做,
隆皮

以上来自于百度翻译


     以下为原文
  Hi,
    I am using exactly the same code and yes I am erasing flash. I just have that problem in case of writing a huge amount of data into flash. e. g. 2MB. Then most of the data is correct but some small blocks are corrupted.
    regards,
    lumpi
举报

更多回帖

发帖
×
20
完善资料,
赚取积分