zoukankan      html  css  js  c++  java
  • i.MX RT1050官方例程 driver_examplesflexspi orpolling_transfer

    RT1050单片机官方SDK(2.5.1和2.5.0这部分都一样)例程中利用flexspi对外部norflash进行擦写,发现扇区擦写函数flexspi_nor_flash_erase_sector存在扇区擦写不能成功的问题,最后分析发现,这个函数擦写之前没有进行spi写使能,代码修改前后对比如下:

    问题扇区擦写代码:

    status_t flexspi_nor_flash_erase_sector(FLEXSPI_Type *base, uint32_t address)
    {
        status_t status;
        flexspi_transfer_t flashXfer;
    
        /* Write enable */
        flashXfer.deviceAddress = address;
        flashXfer.port = kFLEXSPI_PortA1;
        flashXfer.cmdType = kFLEXSPI_Command;
        flashXfer.SeqNumber = 1;
        flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_WRITEENABLE;
    
        status = FLEXSPI_TransferBlocking(base, &flashXfer);
    
        if (status != kStatus_Success)
        {
            return status;
        }
    
        flashXfer.deviceAddress = address;
        flashXfer.port = kFLEXSPI_PortA1;
        flashXfer.cmdType = kFLEXSPI_Command;
        flashXfer.SeqNumber = 1;
        flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_ERASESECTOR;
        status = FLEXSPI_TransferBlocking(base, &flashXfer);
    
        if (status != kStatus_Success)
        {
            return status;
        }
    
        status = flexspi_nor_wait_bus_busy(base);
    
        return status;
    }

    有意思的时函数里面注释的有写使能,但是没有这部分代码,绝对是这位老哥给忘了。

    修改后的代码(高亮背景的是添加的代码):

    status_t flexspi_nor_flash_erase_sector(FLEXSPI_Type *base, uint32_t address)
    {
        status_t status;
        flexspi_transfer_t flashXfer;
    
        /* Write enable */
        status = flexspi_nor_write_enable(base, address);
    
        if (status != kStatus_Success)
        {
            return status;
        }
        
        flashXfer.deviceAddress = address;
        flashXfer.port = kFLEXSPI_PortA1;
        flashXfer.cmdType = kFLEXSPI_Command;
        flashXfer.SeqNumber = 1;
        flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_WRITEENABLE;
    
        status = FLEXSPI_TransferBlocking(base, &flashXfer);
    
        if (status != kStatus_Success)
        {
            return status;
        }
    
        flashXfer.deviceAddress = address;
        flashXfer.port = kFLEXSPI_PortA1;
        flashXfer.cmdType = kFLEXSPI_Command;
        flashXfer.SeqNumber = 1;
        flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_ERASESECTOR;
        status = FLEXSPI_TransferBlocking(base, &flashXfer);
    
        if (status != kStatus_Success)
        {
            return status;
        }
    
        status = flexspi_nor_wait_bus_busy(base);
    
        return status;
    }
  • 相关阅读:
    Java 8 CompletableFuture思考
    Math.ceil 笔记
    Python virtual env
    Reactive Stream: 如何将两个数据流接到一起,然后进行操作
    基于Apollo实现.NET Core微服务统一配置(测试环境-单机)
    在ASP.NET Core 2.x中获取客户端IP地址
    Entity Framework Core(3)-配置DbContext
    .NET Core2.1下采用EFCore比较原生IOC、AspectCore、AutoFac之间的性能
    Entity Framework Core 入门(2)
    Entity Framework Core介绍(1)
  • 原文地址:https://www.cnblogs.com/fancyop/p/RT1050_Flexspi_Q1.html
Copyright © 2011-2022 走看看