-
Notifications
You must be signed in to change notification settings - Fork 539
Description
Operating System
Linux
IDE version
2.3.4
Board
RAK4630/4631
BSP version
1.3.3
Sketch
In a RAK Wireless example, usings a ultasonic module, they use a correction factor (0.7726) for the time returned by PulseIn.
`
digitalWrite(TRIG, LOW);
pinMode(ECHO, INPUT);
respondTime = pulseIn(ECHO, HIGH); // microseconds
delay(33);
if(RAK4631_BOARD)
{
respondTime = respondTime*0.7726; // Time calibration factor is 0.7726,to get real time microseconds for 4631board
}
Serial.printf("respond time is %d\r\n",respondTime);`
I asked them why their module needed a correction. They check the example and the correction is need with the RAK4530/4631, but they had no idea why the adafruit function returned the wrong time for their nrf52.
I looked at the adafruit code in;
I don't fully understand the ASM timing code, but i find all the references to SAMD compilation and directives a little strange.
`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" \
-I/Code/arduino/build/linux/work/hardware/tools/CMSIS/CMSIS/Include/ \
-I/Code/arduino/build/linux/work/hardware/tools/CMSIS/Device/ATMEL/ \
-I/Code/arduino/build/linux/work/hardware/arduino/samd/cores/arduino \
-I/Code/arduino/build/linux/work/hardware/arduino/samd/variants/arduino_zero \
count.c -Wa,-ahlmsd=output.lst -dp -fverbose-asm -S
The result has been slightly edited to increase readability.`
What happened ?
How to reproduce ?
using RAK4631 and RAK baseboard and RAK12007 ultrasound.
Debug Log
No response
Screenshots
No response