打印
[工具和软件]

解析什么是Read 1s命令

[复制链接]
1615|12
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主

最近在看Kinetis的Reference Manual的时候发现一个有意思的命令,即Read 1s。乍一看以为是读1秒的意思(你不要跟我说现在小米都出2s了iPhone都出5s了,这个“1s”太落伍了吧,咳咳,我只能说你手机看多了吧,我可不想落下个给手机做广告的嫌疑,呵呵),不过一结合上下文的话这意思可就差的十万八千里了,无奈之下只能安下心来仔细琢磨一会儿(说实话,这E文读的真是累啊,呵呵,要我说啊,为什么国内的科研水平相比于国外上不去,其中一部分原因是现在的科学文献几乎一色的E文,国人别说理解透彻,首先认全单词都得半天,汗,这效率可想而知了,哎,咳咳,当然我并不是反对英文的重要性,稍微替广大技术发烧友们吐槽一下,呵呵),这才发现其中奥妙,觉着挺有意思的,我google了一下还没有人正式的提到过这个问题,所以还是觉着有必要在这里分享出来,仅供参考。

    首先解释一些这个“1s”,其中“s”其实是英文复数的意思,也就是说很多个1,咳咳,这下长见识了吧,看来“1s”还是个多义词来,原来E文也是博大精深的嘛,哈哈。好了,言归正传,既然1s是多个1的话,那Read 1s就是读多个1出来,而且这个命令又是在Flash模块里用的,我们会联想到什么呢,呵呵,估计很多人都已经猜到了。我们都知道,flash存储器由于其架构的原理,对其读写尤其是写来说有两个过程,即先擦除然后再写,而每个字节被擦除后是为1的(我们对flash的写只能是由1写成0,是不能由0写成1的,这是原理性的问题,也解释了为什么我们写数据的时候要先擦除再写,这下知道原因了吧,呵呵),这下我们再联想Read 1s指令就有点“昭然若揭”了吧,结合文档中的内容我们不难理解“Read 1s”命令其实就是用来确认和验证某段Flash区是否被正确擦除了(全擦除了就读回来的全是1,有一个没擦除干净就会返回擦除错误)。下面我们来看一下K60 RM中的一段指令描述:

    从上图我们可以看到,K60有三个“Read 1s”命令,分别为Read 1s Block(验证某块是否被擦除)、Read 1s Section(验证某段区域是否被擦除)和Read 1s All Blocks(验证所有的块是否被擦除)。至于这几个命令的用处可就大了,在高安全领域的应用,假入我们想写一些重要敏感的数据到某段Flash区中,在对flash擦除之后,为了保险起见可以启动这个命令对擦除的区域进行验证,只有完全擦除了才能写进去,不然擦除的时候漏掉某个地址的字节,而这个字节数据又恰好要被用到,那就有可能发生错误。至于其他应用,靠大家自己去琢磨了,呵呵。

    这里我只是简单的说了说这个Read 1s命令,如果大家不理解可以去Kinetis RM上去慢慢啃慢慢理解


相关帖子

沙发
fhguo1990| | 2015-4-21 17:24 | 只看该作者
用IAR和Jlink调试K60时。如果不选中IAR的use flash loader,则程序便下载不到K60里。不知道是什么原因?

使用特权

评论回复
板凳
我思故我在12345|  楼主 | 2015-4-21 17:25 | 只看该作者
fhguo1990 发表于 2015-4-21 17:24
用IAR和Jlink调试K60时。如果不选中IAR的use flash loader,则程序便下载不到K60里。不知道是什么原因? ...

这个不选肯定是可以的,你说的下载不到K60里是什么现象呢,是弹出错误来吗?

使用特权

评论回复
地板
fhguo1990| | 2015-4-21 17:26 | 只看该作者
我思故我在12345 发表于 2015-4-21 17:25
这个不选肯定是可以的,你说的下载不到K60里是什么现象呢,是弹出错误来吗? ...

Mon Sep 30, 2013 10:09:14: Loaded macro file: C:\Program Files\IAR Systems\Embedded Workbench 6.0\arm\config\flashloader\Freescale\FlashK60Xxxx.mac
Mon Sep 30, 2013 10:09:15: JLINK command: ProjectFile = C:\Documents and Settings\song\桌面\GPIO 实验\build\gpio_demo\settings\fire_gpio_demo_Debug.jlink, return = 0
Mon Sep 30, 2013 10:09:15: JLINK command: device = MK60DN512xxx10, return = 0
Mon Sep 30, 2013 10:09:15: DLL version: V4.36e, compiled Oct 20 2011 21:20:51
Mon Sep 30, 2013 10:09:15: Firmware: J-Link ARM V8 compiled Nov 14 2012 22:34:52
Mon Sep 30, 2013 10:09:15: Selecting SWD as current target interface.
Mon Sep 30, 2013 10:09:15: JTAG speed is initially set to: 32 kHz
Mon Sep 30, 2013 10:09:15: Found SWD-DP with ID 0x2BA01477
Mon Sep 30, 2013 10:09:15: TPIU fitted.
Mon Sep 30, 2013 10:09:15: ETM fitted.
Mon Sep 30, 2013 10:09:15: ETB present.
Mon Sep 30, 2013 10:09:15: CSTF present.
Mon Sep 30, 2013 10:09:15:   FPUnit: 6 code (BP) slots and 2 literal slots
Mon Sep 30, 2013 10:09:15: Found Cortex-M4 r0p0, Little endian.
Mon Sep 30, 2013 10:09:15: Hardware reset with strategy 0 was performed
Mon Sep 30, 2013 10:09:15: Initial reset was performed
Mon Sep 30, 2013 10:09:16: ----- Prepare hardware for Flashloader -----
Mon Sep 30, 2013 10:09:16: 1280 bytes downloaded (7.27 Kbytes/sec)
Mon Sep 30, 2013 10:09:16: Loaded debugee: C:\Program Files\IAR Systems\Embedded Workbench 6.0\arm\config\flashloader\Freescale\FlashK60Xxxx.out
Mon Sep 30, 2013 10:09:16: Target reset
Mon Sep 30, 2013 10:09:16: Skipping flash loading pass because there is no data in the designated range: 0x10000000-0x13FFFFFF.
Mon Sep 30, 2013 10:09:16: Downloaded C:\Documents and Settings\song\桌面\GPIO 实验\build\gpio_demo\Debug\Exe\fire_gpio_demo.out to flash memory.
Mon Sep 30, 2013 10:09:16: Found SWD-DP with ID 0x2BA01477
Mon Sep 30, 2013 10:09:16: TPIU fitted.
Mon Sep 30, 2013 10:09:16: ETM fitted.
Mon Sep 30, 2013 10:09:16: ETB present.
Mon Sep 30, 2013 10:09:16: CSTF present.
Mon Sep 30, 2013 10:09:16:   FPUnit: 6 code (BP) slots and 2 literal slots
Mon Sep 30, 2013 10:09:16: Found Cortex-M4 r0p0, Little endian.
Mon Sep 30, 2013 10:09:17: Hardware reset with strategy 0 was performed
Mon Sep 30, 2013 10:09:17: 7828 bytes downloaded into FLASH (6.52 Kbytes/sec)
Mon Sep 30, 2013 10:09:17: Loaded debugee: C:\Documents and Settings\song\桌面\GPIO 实验\build\gpio_demo\Debug\Exe\fire_gpio_demo.out
Mon Sep 30, 2013 10:09:17: Found SWD-DP with ID 0x2BA01477
Mon Sep 30, 2013 10:09:17: TPIU fitted.
Mon Sep 30, 2013 10:09:17: ETM fitted.
Mon Sep 30, 2013 10:09:17: ETB present.
Mon Sep 30, 2013 10:09:17: CSTF present.
Mon Sep 30, 2013 10:09:17:   FPUnit: 6 code (BP) slots and 2 literal slots
Mon Sep 30, 2013 10:09:17: Found Cortex-M4 r0p0, Little endian.
Mon Sep 30, 2013 10:09:17: Hardware reset with strategy 0 was performed
Mon Sep 30, 2013 10:09:17: Target reset
Mon Sep 30, 2013 10:09:17: There was 1 warning during the initialization of the debugging session.
这是选中use flash loader的debugger log.下面的是没有选中的debugger log。发现两个的区别是在没选use flash loader的log里没有download  。。。。。to flash memeroy一行。所以怀疑没有将程序下到flash中。但是不知道原因是什么?请博主帮分析分析。谢。
Mon Sep 30, 2013 10:05:17: JLINK command: ProjectFile = C:\Documents and Settings\song\桌面\GPIO 实验
\build\gpio_demo\settings\fire_gpio_demo_Debug.jlink, return = 0
Mon Sep 30, 2013 10:05:17: JLINK command: device = MK60DN512xxx10, return = 0
Mon Sep 30, 2013 10:05:17: DLL version: V4.36e, compiled Oct 20 2011 21:20:51
Mon Sep 30, 2013 10:05:17: Firmware: J-Link ARM V8 compiled Nov 14 2012 22:34:52
Mon Sep 30, 2013 10:05:17: Selecting SWD as current target interface.
Mon Sep 30, 2013 10:05:17: JTAG speed is initially set to: 32 kHz
Mon Sep 30, 2013 10:05:17: Found SWD-DP with ID 0x2BA01477
Mon Sep 30, 2013 10:05:18: TPIU fitted.
Mon Sep 30, 2013 10:05:18: ETM fitted.
Mon Sep 30, 2013 10:05:18: ETB present.
Mon Sep 30, 2013 10:05:18: CSTF present.
Mon Sep 30, 2013 10:05:18:   FPUnit: 6 code (BP) slots and 2 literal slots
Mon Sep 30, 2013 10:05:18: Found Cortex-M4 r0p0, Little endian.
Mon Sep 30, 2013 10:05:18: Hardware reset with strategy 0 was performed
Mon Sep 30, 2013 10:05:18: Initial reset was performed
Mon Sep 30, 2013 10:05:19: 7828 bytes downloaded (17.49 Kbytes/sec)
Mon Sep 30, 2013 10:05:19: Loaded debugee: C:\Documents and Settings\song\桌面\GPIO 实验
\build\gpio_demo\Debug\Exe\fire_gpio_demo.out
Mon Sep 30, 2013 10:05:19: Found SWD-DP with ID 0x2BA01477
Mon Sep 30, 2013 10:05:19: TPIU fitted.
Mon Sep 30, 2013 10:05:19: ETM fitted.
Mon Sep 30, 2013 10:05:19: ETB present.
Mon Sep 30, 2013 10:05:19: CSTF present.
Mon Sep 30, 2013 10:05:19:   FPUnit: 6 code (BP) slots and 2 literal slots
Mon Sep 30, 2013 10:05:19: Found Cortex-M4 r0p0, Little endian.
Mon Sep 30, 2013 10:05:19: Hardware reset with strategy 0 was performed
Mon Sep 30, 2013 10:05:19: Target reset

使用特权

评论回复
5
我思故我在12345|  楼主 | 2015-4-21 17:26 | 只看该作者
fhguo1990 发表于 2015-4-21 17:26
Mon Sep 30, 2013 10:09:14: Loaded macro file: C:\Program Files\IAR Systems\Embedded Workbench 6.0\ ...

Mon Sep 30, 2013 10:05:19: 7828 bytes downloaded (17.49 Kbytes/sec)
Mon Sep 30, 2013 10:05:19: Loaded debugee: C:\Documents and Settings\song\桌面\GPIO 实验
\build\gpio_demo\Debug\Exe\fire_gpio_demo.out
我看了下,下面这个也出现了downloaded了,表明已经下载进去了,只不过由于flashloader的不同造成log内容的不同,实际上那个“loaded debugee...”这句表明程序已经下载进去了~为方便区分你这两种情况你试不同的程序就很可疑判断了~

使用特权

评论回复
6
fhguo1990| | 2015-4-21 17:27 | 只看该作者
我思故我在12345 发表于 2015-4-21 17:26
Mon Sep 30, 2013 10:05:19: 7828 bytes downloaded (17.49 Kbytes/sec)
Mon Sep 30, 2013 10:05:19: Lo ...

还是不行,同样一样led的程序,选中use flash loader后,下载完后,就有实验结果。不选中,就没实验结果,就是灯不亮,应该是没下进去吧,或者难道是下进去的地方不对?还是不解

使用特权

评论回复
7
fhguo1990| | 2015-4-21 17:27 | 只看该作者
fhguo1990 发表于 2015-4-21 17:27
还是不行,同样一样led的程序,选中use flash loader后,下载完后,就有实验结果。不选中,就没实验结果 ...

晕,这个奇怪的,我使用jlink的时候一直是不选中flash loader的,用到现在也没发现问题啊。不行的话,你就选中吧,反正也不碍事的~

使用特权

评论回复
8
fhguo1990| | 2015-4-21 17:28 | 只看该作者
fhguo1990 发表于 2015-4-21 17:27
晕,这个奇怪的,我使用jlink的时候一直是不选中flash loader的,用到现在也没发现问题啊。不行的话,你 ...

嗯嗯。多谢。
还有个问题困扰好久了。请博主赐教。就是中断嵌套函数的调用。发现中断嵌套函数写在core_cm4.h里面。比如下面这个函数
static __INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
    {
        if(IRQn < 0)
        {
            return((uint32_t)(SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] >> (8 - __NVIC_PRIO_BITS)));
        } /* get priority for Cortex-M  system interrupts */
        else
        {
            return((uint32_t)(NVIC->IP[(uint32_t)(IRQn)]           >> (8 -  __NVIC_PRIO_BITS)));
        } /* get priority for device specific interrupts  */
    }
问题1:__INLINE可是博主的一篇**提到的内联函数。
问题2:在调用函数时,编译时总是提示IRQn_Type   __NVIC_PRIO_BITS没定义,找了一下,也确实找不到定义。博主可否写篇关于中断嵌套函数调用的**。望不吝赐教。

使用特权

评论回复
9
我思故我在12345|  楼主 | 2015-4-21 17:28 | 只看该作者
fhguo1990 发表于 2015-4-21 17:28
嗯嗯。多谢。
还有个问题困扰好久了。请博主赐教。就是中断嵌套函数的调用。发现中断嵌套函数写在core_cm ...

你这个函数我没有找到,呵呵,还有关于问题一你的问题是?

使用特权

评论回复
10
fhguo1990| | 2015-4-21 17:29 | 只看该作者
我思故我在12345 发表于 2015-4-21 17:28
你这个函数我没有找到,呵呵,还有关于问题一你的问题是?

不是吧?core_cm4.h头文件中有啊。博主可否写篇关于中断函数调用的**呢?我调函数总是出问题

使用特权

评论回复
11
我思故我在12345|  楼主 | 2015-4-21 17:30 | 只看该作者
fhguo1990 发表于 2015-4-21 17:29
不是吧?core_cm4.h头文件中有啊。博主可否写篇关于中断函数调用的**呢?我调函数总是出问题 ...

在CMSIS库里面那个头文件是吗,你把它添加到你的工程里然后调用的吗?请把你的情况说得清楚一些方便理解

使用特权

评论回复
12
我思故我在12345|  楼主 | 2015-4-21 17:30 | 只看该作者
我看了下你的工程,实际上是你的CMSIS库的头文件没有加全,关于IRQn_Tpye等的定义在CMSIS官方库的Device->ARM->ARMCM4->Include路径下的ARMCM4.h头文件里,你可以找找~

使用特权

评论回复
13
FSL_TICS_ZJJ| | 2015-4-27 13:30 | 只看该作者
非常感谢你关于Kinetis的经验分享 !

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

27

主题

318

帖子

9

粉丝