My sketch freezes (with no errors) after 53 sec (13267 scans).
I am using IDE 2.03.
The old NANO, in the same shield runs without problems.
If I remark out tone() and noTone the sketch runs without problems.
Help
Thanks,
Larry
//#include <Wire.h>
//#include <Adafruit_GFX.h>
//#include <Adafruit_SSD1306.h>
unsigned long OUTPUTPIN = 10;
unsigned long SCAN_CNT = 0;
void setup() {
pinMode(OUTPUTPIN, OUTPUT);
} //END SETUP
void loop() {
SCAN_CNT = SCAN_CNT + 1;
Serial.print(" SCAN_CNT= ");
Serial.println(SCAN_CNT);
digitalWrite(OUTPUTPIN, HIGH);
tone(9, 900); //DRIVES SPEAKER
delay(2);
digitalWrite(OUTPUTPIN, LOW);
noTone(9);
delay(2);
} // END LOOP
hi.
nothing wrong with that? Are 9 and 10 two differents pins?
unsigned long OUTPUTPIN = 10;
digitalWrite(OUTPUTPIN, HIGH);
tone(9, 900); //DRIVES SPEAKER
by the way, delay(2) sounds a little short for human ears.
and finally: you will take advantage (and maybe a lot of time to read the board manual) by using PWM generation and configure it according to your needs. The 33 BLE is very powerfull for that.
Thanks for the reply.
Pin 9 is the sound generator. ( a small amplified speaker)
Pin 10 is the LED.
The reason that the time is so short is that I don't want to wait for hours for the freeze.
It will freeze with a delay of 500.
I know I can't see or hear the difference at a delay of 2.
Were you able to duplicate the freeze?
I will need to look at the concept of PWM generation.
Thanks,
Larry
I must confess I don't even try.
allow me a sec.
well. Can we say I really "overyou" ?:
I am freezing at 13275 but miss the last line with my scrrenshot.
Allow me another sec to test some stuff.
EDIT: stuff didn't work, I see the board freezing at 13275. My poor help suggestion is: forget about the tone function for your BLE.
I can not confirm the issue. I and can see high counts like this
SCAN_CNT= 10258
SCAN_CNT= 10259
SCAN_CNT= 10260
SCAN_CNT= 10261
What mbed core are you using?
There was an issue in the past, but should be fixed.
https://github.com/arduino/Arduino/issues/10322
I don't see the issue with core 3.5.4 which is the latest release. See this detail if you enable detailed output during compile in Preferences in the ide window.
Using board 'nano33ble' from platform in folder: C:\Users\YourName\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\3.5.4
Using core 'arduino' from platform in folder: C:\Users\YourNane\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\3.5.4
please see both OP and me get higher number (roughly 13275) and then freeze.
please see both OP and me get higher number (roughly 13275) and then freeze.
My apologies. You are correct. I also freeze at a count of 13725.
no apologies expected, but I will take the confirmation
your link could confirm what I had in mind with no evidence : tone function must be the root of the issue.
cattledog
From what I can tell I am using core 3.5.4
Thanks
I went to gthub.
My IDE (2.04) doesn't have "Arduino Mbed OS Boards (nRF52840 / STM32H747)" for a selection.
Don't know why.
Thanks
I think it is deprecated and there are now variants in 3.5.4.
This tone function using Mbed did not freeze after 2000000 scans.
Thanks Mr. Hoang.
/****************************************************************************************************************************
PWM_Single.ino
For Nano_33_BLE or Nano_33_BLE_Sense boards
Written by Khoi Hoang
Built by Khoi Hoang https://github.com/khoih-prog/nRF52_MBED_PWM
Licensed under MIT license
*****************************************************************************************************************************/
#if !( ARDUINO_ARCH_NRF52840 && TARGET_NAME == ARDUINO_NANO33BLE )
#error This code is designed to run on nRF52-based Nano-33-BLE boards using mbed-RTOS platform! Please check your Tools->Board setting.
#endif
#define _PWM_LOGLEVEL_ 1
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include "nRF52_MBED_PWM.h"
// All the digital pins on Arduino Nano 33 BLE sense are PWM-enabled pins which are numbered from D0 to D13
uint32_t myPin = D9;
uint8_t LED4_PIN = 10;
float dutyCycle = 50.0f;
float freq = 800.0f;
uint32_t SCAN_CNT;
mbed::PwmOut* pwm = NULL;
void setup()
{
setPWM(pwm, myPin, freq, dutyCycle);
pinMode(myPin, OUTPUT);
pinMode(LED4_PIN, OUTPUT);
digitalWrite(myPin, LOW);
Serial.begin(115200);
} //end setup
void loop()
{
SCAN_CNT++ ;
digitalWrite(LED4_PIN, HIGH);
setPWM(pwm, myPin, freq, dutyCycle);//starts tone
delay(1000);
Serial.println(SCAN_CNT);
stopPWM(pwm, myPin); //stops tone
digitalWrite(LED4_PIN, LOW);
delay(500);
} //end loop
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.