简体   繁体   English

当 µc (nRF52840) 进入休眠模式时,我们如何保存他起床后要使用的数据?

[英]when the µc (nRF52840) is passing into sleep mode how can we save Data that we want to use later when he's up?

I m working on an nRF52840 µc,the µc will be woken up every 3 hours and i have to save a data(4bytes) into a tab[16] so i can send those 16 values later after 2 days.我在 nRF52840 µc 上工作,µc 每 3 小时被唤醒一次,我必须将数据(4 字节)保存到选项卡 [16] 中,这样我就可以在 2 天后发送这 16 个值。

Not familiar with the part but looking at the reference manual, the on-chip RAM is static meaning that it will retain its value so long as the power supply is maintained - even in sleep modes or through a reset.不熟悉该部件,但查看参考手册,片上 RAM 为 static,这意味着只要保持电源供电,它就会保持其值 - 即使在睡眠模式下或通过重置。 You would need to set-up the link map and start-up code to avoid initialising the reserved area on start-up.您需要设置链接 map 和启动代码以避免在启动时初始化保留区域。

Alternatively, the 256K flash memory is divided into 4K erase-block pages, you could reserve an entire page (ie set the link map to avoid locating code there).或者,将 256K flash memory 分成 4K 个擦除块页面,您可以保留整个页面(即设置链接 map 以避免在此处定位代码)。 The flash endurance is only 10000 erase cycles, but even if you erases the block every two days, it would last >54 years. flash 的耐久度只有 10000 次擦除周期,但即使你每两天擦除一次块,它也会持续 >54 年。 Since you are writing a data block of only 64 bytes you could write the blocks sequentially through the 4K such that the highest addressed non-blank block of 64 bytes is the current data;由于您正在写入只有 64 字节的数据块,因此您可以通过 4K 顺序写入块,这样最高地址的 64 字节非空白块就是当前数据; then you need only erase the page once it is entirely full, extending the endurance to 3500 years.然后您只需要在页面完全写满后擦除页面,将耐用性延长至 3500 年。

Note however that the flash as some restrictions:但请注意 flash 作为一些限制:

  • It must be written in 32 bit words必须用32位字写
  • A 32-bit word can only be written twice before it must be erased for be writable again.一个 32 位字只能写入两次,然后必须擦除才能再次写入。

That is to say you can write say 0xFFFFFF00, then 0xFFFF00FF, and the word would then contain 0xFFFF0000, but you could not then write the upper two bytes of that word.也就是说,你可以先写 0xFFFFFF00,然后写 0xFFFF00FF,然后这个字就会包含 0xFFFF0000,但是你不能再写那个字的高两个字节。

Another issue with using the Code Flash is that while erasing, the bus stalls and instructions cannot be fetched.使用代码 Flash 的另一个问题是,在擦除时,无法获取总线停顿和指令。 That means your code stops running.这意味着您的代码停止运行。 This scan be a serious issue in real-time systems;这种扫描在实时系统中是一个严重的问题; but given that your system sleeps for 3 hours at a time, presumably there are no critical micro-second level timing deadlines?但鉴于您的系统一次休眠 3 小时,大概没有关键的微秒级计时期限?

Another possibility offered by part is the UICR (User information configuration registers), a special area of non-volatile memory that includes 32 words (128 bytes) of customer defined data.部件提供的另一种可能性是 UICR(用户信息配置寄存器),非易失性 memory 的一个特殊区域,包括 32 个字(128 字节)的客户定义数据。 However that is perhaps not very practical for dynamic storage since the area contains Nordic reserved words and device configuration, and like regular flash memory an erase deleted the entire UICR, so you would necessarily copy the data before erase and rewrite it.然而,这对于动态存储来说可能不太实用,因为该区域包含 Nordic 保留字和设备配置,并且像常规 flash memory 擦除删除整个 UICR,因此您必须在擦除和重写之前复制数据。 Not really power fail safe.不是真正的电源故障安全。 The endurance is still 10000 erase cycles, if you striped it like above, having only 128 bytes would extend the endurance to 20000 cycles or 109 years erasing every 4 days.耐久性仍然是 10000 次擦除周期,如果你像上面那样条带化它,只有 128 字节将耐久性延长到 20000 次周期或每 4 天擦除 109 年。

Beyond those possibilities an off-chip NV memory device such as an EEPROM, FRAM, Flash, or even and SD/MMC card (with a filesystem).除了这些可能性之外,还有片外 NV memory 设备,例如 EEPROM、FRAM、Flash,甚至是 SD/MMC 卡(带有文件系统)。 These can be attached via one of the available SPI, I 2 C (TWI) or QSPI interfaces.这些可以通过可用的 SPI、I 2 C (TWI) 或 QSPI 接口之一连接。 Whist likely to have higher endurance than the on-chip flah, that may still be a consideration for some devices. Whist 可能比片上 flah 具有更高的耐用性,这可能仍然是某些设备的考虑因素。 FRAM has no endurance issues, and SD cards are so capacious that it is unlikely to be an issue in the application described. FRAM 没有耐久性问题,而 SD 卡的容量非常大,因此在所描述的应用中不太可能成为问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM