Low level library NRF52

Posted on
    1. var ll = require("NRF52LL");
    2. var saadc = ll.saadc({
    3. channels : [ { // channel 0
    4. pin:D29,
    5. gain:1/4,
    6. tacq:40,
    7. refvdd:true,
    8. } ]
    9. });
    10. setInterval(function() {
    11. print(saadc.sample()[0]);
    12. }, 250);

    How do i change the resolution to 10 bits and Internal reference ?

  • Check out http://www.espruino.com/NRF52LL#reference

    I'll just copy the relevant bit below:

    1. /* Successive approximation analog-to-digital converter
    2. opts is {
    3. channels : [ {
    4. pin : D0, // pin number to use,
    5. npin : D1, // pin to use for negative input (or undefined)
    6. pinpull : undefined / "down" / "up" / "vcc/2", // pin internal resistor state
    7. npinpull : undefined / "down" / "up" / "vcc/2", // npin internal resistor state
    8. gain : 1/6, 1/5, 1/4, 1/3, 1/2, 1(default), 2, 4, // input gain -
    9. refvdd : bool, // use VDD/4 as a reference (true) or internal 0.6v ref (false)
    10. tacq : 3(default),5,10,15,20,40 // acquisition time in us
    11. }, { ... } ] // up to 8 channels
    12. resolution : 8,10,12,14 // bits (14 default)
    13. oversample : 0..8, // take 2<<X samples, 0(default) is just 1 sample
    14. samplerate : 0(default), 80..2047 // Sample from sample task, or at 16MHz/X
    15. dma : { ptr, cnt } // enable DMA. cnt is in 16 bit words
    16. // DMA IS REQUIRED UNLESS YOU'RE JUST USING THE 'sample' function
    17. }
    18. returns {
    19. status, // 0=ready, 1=busy
    20. config, // address of config register
    21. enable,
    22. amount, // words transferred since last tStart
    23. tStart, // Start ADC
    24. tSample, // Start sampling
    25. tStop, // Stop ADC
    26. tCalib, // Start calibration
    27. eDone // event when GPIO changes
    28. eEnd // ADC has filled DMA buffer
    29. setDMA : function({ptr,cnt}) // set new DMA buffer
    30. // double-buffered so can be set again right after tStart
    31. sample : function(cnt) // Make `cnt*channels.length` readings and return the result. resets DMA
    32. }
    33. */
    34. exports.saadc = function (opts) { ... }

    so...

    1. var saadc = ll.saadc({
    2. resolution : 10, // <--- HERE
    3. channels : [ {
    4. ...
    5. refvdd:false, // <--- HERE
  • gordon

    Thank you so much!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
    • $ Donate
About

Low level library NRF52

Posted by Avatar for user95229 @user95229

Actions