RAK4630/4631 pulseIn() function

I found this code in the RAK12007 example code.

respondTime = pulseIn(ECHO, HIGH); // microseconds
if(RAK4631_BOARD)
{
     // Time calibration factor is 0.7726,to get real time microseconds for 4631board
     respondTime = respondTime*0.7726; 
}

found in;

RAK12007 example

I looked in the Adafruit_nRF52_Arduino github for any pulseIn issues. I find nothing.

Can somebody explain why scaling the pulseIn () funtion return is required for Rak463X?

Hi @sspw ,

I did check on my own sensor as well as on the non-wisblock ultrasonic sensor (the generic ones). The scaling seems to be needed. Without it, the reading is higher.

I have no another board than 4630 that can test with adafruit pulsein. But it can be on the implementation on pulsein. Quick search shows it is software implemented. Maybe some tolerance (but I have no exact idea).

i see adafruit is pulseIn is doing a timing loop in assembly.

PulseIn

countPulseASM

might be an issue in the asm, as it seems to make reference to SAMD not NRF52

using the command line:

    arm-none-eabi-gcc -mcpu=cortex-m0plus -mthumb -c -Os -W -ffunction-sections -fdata-sections \
                      -nostdlib --param max-inline-insns-single=500 -fno-exceptions -MMD \
                      -DF_CPU=48000000L -DARDUINO=10602 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD \
                      -D__SAMD21G18A__ -DUSB_VID=0x2341 -DUSB_PID=0x004d -DUSBCON \
                      -DUSB_MANUFACTURER="Arduino LLC" -DUSB_PRODUCT="Arduino Zero" \