This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Pstorage with S210 softdevice

Hi Nordic!

Long time short, I want to do an ANT application (S210, nRF51422) that pairs two slaves to one master. I have configured everything such that it pairs only when the master is close to the slaves. Now, I want that, when I send a determined message to the slaves, they save that channel ID information in some non-volatile memory (flash).

I am trying to do this using the driver pstorage, but I am having a lot of troubles to set it up. I have seen that other people (devzone.nordicsemi.com/.../) have had the same problem, but still am not able to solve the problem.

The kind of errors I am getting, are the same that the guy from that question I referenced had:

ble.h missing, but when I solve it I get more different errors.

Is there any easy way of doing this? Has anyone tried to do this as well? I would appreciate if someone had an example of writing in flash using S210 softdevice.

Thanks a lot!

  • I'm not familiar with what you describe, but installing something in Keil wouldn't add support for S210 in SDK 12.1.0. SDK 10.0.0 is the last SDK that supported S210, so if I were you, I would use that. And rather port parts of SDK 12.1.0, if there is a certain feature that you need. I can try to make an example using the sd_flash* API with SDK 10.0.0. if you want.

  • Hi again! Thanks for fast reply!

    When I installed SDK v12.1, my keil had examples related to ant (if this behavior is not common, maybe I did something before, but I certainly dont think so). Nevermind, I will install SDK 10.0.

    It would be nice if you could put a minimal example of how to write to and read from non-volatile memory using this sd_flash_write(). Would really appreciate it.

    Thanks!

  • Here is the example, extract to examples\ant

    I used the broadcast_rx example as a starting point.

    I tried to put in //angel start and //angel start where I made changes.

    On boot (see boot()) it will read the byte stored at 0x3FC00 in flash, and increment it.

    It will then set an erase flag, and erase the 0x3FC00 page (the 255th (0xFF) page).

    If the erase is successful the NRF_EVT_FLASH_OPERATION_SUCCESS event will be received in sys_evt_dispatch(). Here the erase flag is cleared and the write operation is started.

    If the write is successful the NRF_EVT_FLASH_OPERATION_SUCCESS event will be received and the write flag will be cleared.

    If the NRF_EVT_FLASH_OPERATION_ERROR event is received the operations will be restarted.

    It shound't be too hard to expand this to the functionality you want.

    This example is given as is, and is not well tested. And I have not tested together with the radio, but I dont' think it will be a problem as long as channel period isn't too short, then you might see NRF_EVT_FLASH_OPERATION_ERROR events.

    You can check the memory address by using nrfjprog --memrd 0x0003FC00 (or memory view in Keil).

  • Thank you a lot Petter for the time spent in making an example. Will totally save me a lot of development time. Will report with the results. Thanks!

  • Hi again Petter,

    I have been trying your example and it works like a charm! Thanks a lot! My question now is, is it always necessary to erase the memory before actually writing to it? From your example I infer that yes, it is. Can you confirm?

    Thanks again!

Related