Heyy guys
facing an issue observe 5 spikes every 100ms from 2uA to 23uA unable to understand whats the issue
i tried multiple ways , those didnt worked i cimmented them
here is following snipet
//----------------------------------------------------------------------------------------------
// BSP : Seeed nRF52 Borads 1.1.1
// Board : Seeed nRF52 Boards / Seeed XIAO nRF52840 Sense
// important : need for Serial.print() <Arduino.h> <Adafruit_TinyUSB.h>
// \Arduino15\packages\Seeeduino\hardware\nrf52\1.1.1\libraries\Bluefruit52Lib\src
//----------------------------------------------------------------------------------------------
// 2023/07/07
// Central sketch : nRF52_XIAO_LightSleepAdvScan_central.ino
// Need to be deleted /Documents/Arduino/libraries/SdFat
#include <nrf_rtc.h>
#include <Arduino.h>
//#include <Adafruit_TinyUSB.h> // For Serial.print()
#include <bluefruit.h> // \Arduino15\packages\Seeeduino\hardware\nrf52\1.1.1\libraries\Bluefruit52Lib\src
#include <Adafruit_SPIFlash.h> // Need to be deleted /Documents/Arduino/libraries/SdFat
#define SLEEP_TIME 30 // Sleep time [sec]
//#define SLEEP_TIME 30 // Sleep time [sec]
Adafruit_FlashTransport_QSPI flashTransport;
//uint8_t timeout = 5;
void setup() {
// Serial port initialization
//Serial.begin(115200);
//while ((!Serial) && (timeout)){
// delay(1000);
// timeout–;
// Enable DC-DC converter
NRF_POWER->DCDCEN = 1; // Enable DC/DC converter for REG1 stage
// Sleep QSPI flash
flashTransport.begin();
flashTransport.runCommand(0xB9); // enter deep power-down mode
flashTransport.end();
//NRF_UART0->ENABLE = 0; // Disable UART
//NRF_SPI0->ENABLE = 0; // Disable SPI
//NRF_TWI0->ENABLE = 0; // Disable I2C
//Bluefruit.begin();
//Bluefruit.Advertising.start();
//Bluefruit.Advertising.stop();
//Bluefruit.end();
//RTC initialization
initRTC(32768 * SLEEP_TIME); // SLEEP_MTIME [sec]
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
// Initialization of Bruefruit class
// Bluefruit.begin();
//Bluefruit.setTxPower(4); // Check bluefruit.h:151 for supported values
//Bluefruit.autoConnLed(false); // turn off LED to save power Sleep Current 4uA
// Bluefruit.setConnLedInterval(50); // Should not be used, Sleep current 300uA
suspendLoop();
// Serial.println(“End of initialization”);
}
//*************************************************************************************************************
void loop() {
// Bluefruit.Advertising.stop();
//delay(5000);
//digitalWrite(LED_BLUE, LOW); // turn the LED on (HIGH is the voltage level)
//delay(5000); //Led on // light for 5 seconds, but the rtc in the background keeps running. → light off only for 25 seconds
//digitalWrite(LED_BLUE, HIGH);
//enterLowPowerState();
// delay(SLEEP_TIME * 1000);
// Sleep
__WFI();
__SEV();
__WFI();
// System ON Sleep by FreeRTOS
}
//**************************************************************************************************************
// RTC initialization
void initRTC(unsigned long count30)
{
// See “6.22 RTC - Real-time counter 6.22.10 Registers”
NRF_CLOCK->TASKS_LFCLKSTOP = 1;
NRF_CLOCK->LFCLKSRC = 1; // select LFXO
NRF_CLOCK->TASKS_LFCLKSTART = 1;
while(NRF_CLOCK->LFCLKSTAT != 0x10001)
NRF_RTC2->TASKS_STOP = 1; // stop counter
NRF_RTC2->TASKS_CLEAR = 1; // clear counter
NRF_RTC2->PRESCALER = 0; // set counter prescaler, fout=32768/(1+PRESCALER) 32768Hz
NRF_RTC2->CC[0] = count30; // set value for TRC compare register 0
NRF_RTC2->INTENSET = 0x10000; // enable interrupt CC[0] compare match event
NRF_RTC2->EVTENCLR = 0x10000; // clear counter when CC[0] event
NVIC_SetPriority(RTC2_IRQn,3); // Higher priority than SoftDeviceAPI
NVIC_EnableIRQ(RTC2_IRQn); // enable interrupt
NRF_RTC2->TASKS_START = 1; // start Timer
}
//**************************************************************************************************************
// RTC interrupt handler
extern “C” void RTC2_IRQHandler(void)
{
if ((NRF_RTC2->EVENTS_COMPARE[0] != 0) && ((NRF_RTC2->INTENSET & 0x10000) != 0)) {
NRF_RTC2->EVENTS_COMPARE[0] = 0; // clear compare register 0 event
NRF_RTC2->TASKS_CLEAR = 1; // clear counter
//intFlag = true;
//digitalWrite(LED_RED, LOW);
//delayMicroseconds(10000); // for LED
//digitalWrite(LED_RED, HIGH);
}
}
following is ouput observed on PPK
@PJ_Glasso @iggzzzz @daCoder @hobbya @1melc @msfujino