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

Nrf52840 ds18b20

Hi team,

There is connection between nrf52840 and ds18b20. I have made simple lib for ds18b20. When i get temerature without softdevice (s140) all works correct (use 9-bit resolution), as soon as i try to use softdevice i get random value from ds18b20. I tried to disable interrupts from softdevice while reading fromds18b20, but in this case SD crashed. What could be the problem? thanks

Parents
  • Hi,

    Just a shot in the dark but try setting in the sdk_config.h NRF_SDH_DISPATCH_MODEL to 2 if you have not tried that.

    // <i> NRF_SDH_DISPATCH_MODEL_INTERRUPT: SoftDevice events are passed to the application from the interrupt context.
    // <i> NRF_SDH_DISPATCH_MODEL_APPSH: SoftDevice events are scheduled using @ref app_scheduler.
    // <i> NRF_SDH_DISPATCH_MODEL_POLLING: SoftDevice events are to be fetched manually.
    // <0=> NRF_SDH_DISPATCH_MODEL_INTERRUPT 
    // <1=> NRF_SDH_DISPATCH_MODEL_APPSH 
    // <2=> NRF_SDH_DISPATCH_MODEL_POLLING 
    
    #ifndef NRF_SDH_DISPATCH_MODEL
    #define NRF_SDH_DISPATCH_MODEL 2
    #endif

    The problem is that this BLE needs specific timings and thus most of the highest priority level interrupts are taken by the softdevice, so this will mess with the bit-bang approach of the one-wire protocol. You will save yourself a lot of headache by adding in another micro (or some protocol converter); ATtiny series comes to mind; and use that to pass the data to the NRF via uart, spi or twi.

    Regards,

  • Hi, is it possible to use one of hardware timer (for instance timer4) to count delays for 1-wire together with BLE? If so, is it possible to setup HW timer to generate 1us period?

Reply Children
Related