Library conflicts nRF52840 Sense

Hi there,
Without seeing the actual Code in Question, Perhaps you need an additional LIB installed for RTC or interrupts.?
are you using the builtin TimeStamp function?
HTH
GL :slight_smile: PJ

Hello PJ,

is there anything to control the timers? In the past, in Assembler you had complete control of the 2 Microchip timers…

There is no difference between using multiple delayMicroseconds and using millis(). (unsigned long).

Just to clarify: I have to generate a servo pulse with a frequency of 125 Hz (8 ms for one complete pulse). The HIGH duration is calculated when the servo signal is LOW. During this LOW time, I measure the x and y values two times (3 ms separated), calculate the averages, and calculate the duration of the next HIGH duration.
So, I cannot use the Arduino servo library.

The problem is, that the calculations are OK, but on the scope I see that the HIGH and LOW durations now and then are exceeded for one to two ms, but not constantly…

Regards,

Wolfgang

Hi there,
Without Seeing the code, I can’t offer much help.
Yes, There is an Interrupts Library and a Timer Library both for Nrf52840 , I don’t have links but you can search here for the examples folks have posted. Sounds like that is what you need.
HTH
GL :slight_smile: PJ

Hello PJ.

Yes, the example blink_print in the timer library is interesting. But I do not understand the toggle principle.
My timer needs pulse of 1 to 2 ms. Then, in the LOW time, the duration of the next pulse is calculated.
Then, after 8 ms since the beginning of the first pulse, everything happens again.
Could you lease look at that sketch, and give me an indication for the solution?
Kind regards,

Wolfgang
P.S Started 50 years ago with FORTRAN. :slight_smile:

Hi there,
LOL, man I vaguely remember some Fortran77 back in the 80"s ? Punch cards too. WOW
The Nrf52840 has Several timers and the PWM’s You can use either.
to achieve the outcome, Check out how Arduino generates Pulses link

Basically set the pulse length, attach an Interrupt, In the ISR reset the timer value start the duty cycle timer with interrupt and rinse and repeat.
like this one, it’s also applicable to Xiao.

HTH
GL :slight_smile: PJ
I’ll look at the blink_print time permitting :wink:and make some comments. :v:

Thanks for the suggestions,
The TimerOne library looked perfect, but it seems not to work with my Xiao Sense, The examples will not compile…
Tried also to change the frequency of the Servo library. Was not able to change the Refresh Interval to 8000 instead of 20000… Still stuck…

Rgards,

Wolfgang

Hi there,
Have you tried the other BSP? In the board selection Pick the second one. What is the BSP that is NOT compiling? Look at compiler output and see which it is.?
HTH
GL :slight_smile: PJ

Hello PJ,

tried both BSPs. Compiler always says "class TimerOne " has no member named ‘initialize’

Rads
Wolfgang

Hi there,
Yes that’s not uncommon for older setups, and that’s for an AVR.
Try this one and you’ll see the Seeed board is called out and supported , BSP 1.0.X

HTH
GL :slight_smile: PJ

PS> DO NOT USE Timer (0) ZERO… or :bomb: :face_with_peeking_eye:

Hello PJ,

Coming nearer.
Modifying TimerInterruptLEDDemo, I could use one timer for a short blink, following by a second timer for a longer pause.
But this sketch is only in milliseconds, and I need the first timer in microseconds…
Suggestion?

Thanks for your patience,

Wolfgang

Hello PJ,

Is there a way to reset the Bluetooth system? It is only used at the beginning of the sketch, to start the main program.

Regards,

Wolfgang

Hi there,
Great to hear that, There is a learning curve but it’s not Too heavy a lift though.
Here are some ways to stop BLE on an nRF52840:

  • Start and stop advertising: Use sd_ble_gap_adv_start() and sd_ble_gap_adv_stop()
  • Disconnect from the central: Use sd_ble_gap_disconnect() while in a connection
  • Stop scanning with BLE.end(): While the peripheral is off, stop scanning with BLE.end()
  • Disable completely the 2.4Ghz radio: After the 52840 has full soft device enabled and ble stack has been run, disable completely the 2.4Ghz radio

HTH
GL :slight_smile: PJ

Hello PJ,

the sd commands were not accepted, but “BLE.end” worked!!! Golden Tip!!
Many thanks,

Wolfgang

Result:


Bye,
Wolfgang

Hi there,
SWEET!
Incrementally moving forward… NICE!
GL :slight_smile: PJ

good to learn from it. dear.

Hello PJ,

my application allows only 6 milliseconds to measure x and y accelerations.
Using myIMU.readFloatAccelX(), each measurement takes between 651 and 670 microseconds. This allows for 8 measurements, which works, but I would like somewhat more samples. Is there a method to measure x and y at the same time?

Regards,

Wolfgang

Hi there,
Have a look at the data sheet that seems kind of low, If you use High performance mode, Higher clock, probably do better.
HTH
GL :slight_smile: PJ

Hello PJ,

tried all the Arduino IMU examples, always >650 µs.
No idea how to modify IMU readings, or what is behind “!2C_MODE”.

Regards,

Wolfgang

Hi there,
What about I2C clock speed or buss speed? any adjustments there?
With out seeing the code , Hard to see where you can gain. What the use case your attempting to satisfy.
HTH
GL :slight_smile: PJ