硬汉嵌入式论坛

 找回密码
 立即注册
查看: 182|回复: 0
收起左侧

[脱机烧录] 烧录串行Flash之后自动设置 QE = 1 (启用四线模式)

[复制链接]

761

主题

1054

回帖

3342

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
3342
发表于 2026-1-28 16:28:55 | 显示全部楼层 |阅读模式


添加如下高级脚本即可

[Lua] 纯文本查看 复制代码
function DoAfterProg(void)
        local s0
        local n0, n1
        
        --新增写状态字 QE = 1
        print("Write QE = 1")
        print_hex(pg_iap("SPI_FLASH", "send_and_recive", "\x9F", 3)) --读flash ID
        pg_iap("SPI_FLASH", "send_and_recive", "\x06", 0)   --允许写
        pg_iap("SPI_FLASH", "send_and_recive", "\x31\x02", 0) --写QE=1  (非易失,掉电会保持)
        
        s0 = pg_iap("SPI_FLASH", "send_and_recive", "\x05", 1); --读状态字低8位
        n0 = string.byte(s0, 1)
        s0 = pg_iap("SPI_FLASH", "send_and_recive", "\x35", 1); --读状态字高8位
        n1 = string.byte(s0, 1)
        
        str = string.format("Status Bytes = 0x%02X%02X", n1,n0)
        print(str)

        --烧录完毕的动作【无需修改】
        if (RESET_AFTER_COMPLETE == 0) then
                --不动作
        elseif (RESET_AFTER_COMPLETE == 1) then
                --print("烧录完毕,已执行reset复位")
                pg_reset()
        elseif (RESET_AFTER_COMPLETE == 2) then
                --print("烧录完毕,已执行断电复位")
                set_tvcc(0) delayms(500) set_tvcc(TVCC_VOLT)
        elseif (RESET_AFTER_COMPLETE == 3) then
                --print("烧录完毕,已断电")
                set_tvcc(0)
        end                
end




串行Flash状态字QE设置1.lua (1017 Bytes, 下载次数: 1)

QE1.png

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2026-2-24 07:23 , Processed in 0.057798 second(s), 27 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表