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!

Parents
  • 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).

  • 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!

Reply Children
No Data
Related