nRF5 action!
-
@NeverDie
He has not added that facility yet,i think he asked you if you wanted it adding to the code? -
for unused pins, it should be floating, not pullup. set the pin register you need to 0x02.
Something like that
NRF_GPIO->PIN_CNF[ulPin] = 0x02;
that will put pin in same state like it's on reset. Everything disabled/default, floating, with disconnect bit set.
(see datasheet gpio).@d00616 said in nRF5 Bluetooth action!:
Should I add a DISCONNECTED mode to hwPinMode()?
make sense to have it for input too.. i agree :simple_smile:
-
Maybe add:
OUTPUT_D0D1 -> Disconnected 0, Disconnected 1
or similar to your list as another easy way to effectuate the disconnect? -
It finally makes sense now as to why there were all those "disconnected" choices among the various OUTPUT options. In my case, for controlling whether the solar panel is connected or disconnected, choosing OUTPUT_S0D1 works perfectly. :)
So, I suppose another way to disconnect an input pin would be to redefine it as an OUTPUT pin with a disconnect state, and then immediately put it into the disconnected state.
-
@rmtucker said in nRF5 Bluetooth action!:
Yes being able to change the prescaler dynamically would help a great deal as 125ms / 582.542 hours is not really useful for most applications with a 250ms overrun.
The sleep() function is now more precise for sleeping <512s:
https://github.com/mysensors/MySensors/pull/909
The PR is waiting for merge.
@d00616 said in nRF5 Bluetooth action!:
@rmtucker said in nRF5 Bluetooth action!:
Yes being able to change the prescaler dynamically would help a great deal as 125ms / 582.542 hours is not really useful for most applications with a 250ms overrun.
The sleep() function is now more precise for sleeping <512s:
https://github.com/mysensors/MySensors/pull/909
The PR is waiting for merge.
Hmm just tried the latest commit and it is giving me 306ms for sleep(10000).
Something not quite right. -
@d00616 said in nRF5 Bluetooth action!:
@rmtucker said in nRF5 Bluetooth action!:
Yes being able to change the prescaler dynamically would help a great deal as 125ms / 582.542 hours is not really useful for most applications with a 250ms overrun.
The sleep() function is now more precise for sleeping <512s:
https://github.com/mysensors/MySensors/pull/909
The PR is waiting for merge.
Hmm just tried the latest commit and it is giving me 306ms for sleep(10000).
Something not quite right. -
@NeverDie said in nRF5 Bluetooth action!:
@rmtucker
How are you measuring how long it's sleeping?Just using hwMillis() before and after sleep and subtracting one from the other.
It was just reading + 250ms until @d00616 commited some changes a few hours ago. -
@NeverDie said in nRF5 Bluetooth action!:
@rmtucker
How are you measuring how long it's sleeping?Just using hwMillis() before and after sleep and subtracting one from the other.
It was just reading + 250ms until @d00616 commited some changes a few hours ago.something wrong in here:-
// Calculate sleep time and prescaler if (ms<512000) { // prescaler 0, 30.517 μs resolution -> max 512 s sleep MY_HW_RTC->PRESCALER = 0; // Set compare register to 1/30.517 µs to garantee event triggering // A minimum of 2 ticks must be guaranteed // (1000/32768)<<12 == 125 MY_HW_RTC->CC[0] = max((ms<<12 / 125), 2); } else { // 8 Hz -> max 582.542 hours sleep. MY_HW_RTC->PRESCALER = 4095; // Set compare register to 1/125ms // A minimum of 2 ticks must be guaranteed MY_HW_RTC->CC[0] = max((ms / 125), 2); } -
@NeverDie said in nRF5 Bluetooth action!:
@rmtucker
How are you measuring how long it's sleeping?Just using hwMillis() before and after sleep and subtracting one from the other.
It was just reading + 250ms until @d00616 commited some changes a few hours ago.@rmtucker said in nRF5 Bluetooth action!:
@NeverDie said in nRF5 Bluetooth action!:
@rmtucker
How are you measuring how long it's sleeping?Just using hwMillis() before and after sleep and subtracting one from the other.
It was just reading + 250ms until @d00616 commited some changes a few hours ago.I thought so. The point being: doesn't millis stop when you're deep sleeping? Well, at least on an Arduino it does. Not sure what it does on the nRF5.
-
@rmtucker said in nRF5 Bluetooth action!:
@NeverDie said in nRF5 Bluetooth action!:
@rmtucker
How are you measuring how long it's sleeping?Just using hwMillis() before and after sleep and subtracting one from the other.
It was just reading + 250ms until @d00616 commited some changes a few hours ago.I thought so. The point being: doesn't millis stop when you're deep sleeping? Well, at least on an Arduino it does. Not sure what it does on the nRF5.
-
@NeverDie
No the nrf5 has a rtc.(Real time Counter)
It can even keep time while sleeping.(just found this out myself!).
That is a great leap forward on the arduino. -
Try it just print the time out then put it to sleep for a minute then print the time out again.
-
The problem must be this line but i don't speak nrf5.:frowning:
// (1000/32768)<<12 == 125 MY_HW_RTC->CC[0] = max((ms<<12 / 125), 2);``` -
@NeverDie said in nRF5 Bluetooth action!:
Thanks! I just now ordered one of your boards so that in the future we can share a common platform for comparing numbers.
Ok. I have measured my Ebyte with the same sketch and in the µA range of my VC165 multimeter. Sleep current is 9.9µA with two ports in INPUT_PULLUP and one Port in OUTPUT_H0H1 mode. (b.t.w. this module costs actually 3,82€)
@scalz said in nRF5 Bluetooth action!:
in that case, you need to set it as a floating input i think, like it's generally at reset.
In datasheet, section 20 (p111), is explained how works the GPIO. You have a Bit for disconnecting it. See the PIN_CNF[n] registers. For instance, p.140, you can see how it looks for the P0.10, and the Bit 1.
This should do the job..Should I add a DISCONNECTED mode to hwPinMode()?
-
MY_HW_RTC->CC[0] = max((ms<<12 / 125), 2);
Should be:-
MY_HW_RTC->CC[0] = max(((ms << 12) / 125), 2));
-
Epilog: I made the changes so that just prior to taking a measurement the sense pin is hwPinMode'd to an input pin, and then immediately after the measurement I disconnect it. Seems to be working, and without the usurious power drain I was experiencing previously. :)
-
Epilog: I made the changes so that just prior to taking a measurement the sense pin is hwPinMode'd to an input pin, and then immediately after the measurement I disconnect it. Seems to be working, and without the usurious power drain I was experiencing previously. :)
@NeverDie said in nRF5 Bluetooth action!:
Epilog: I made the changes so that just prior to taking a measurement the sense pin is hwPinMode'd to an input pin, and then immediately after the measurement I disconnect it. Seems to be working, and without the usurious power drain I was experiencing previously. :)
Good news
So what is the current usage now when sleeping? -
@NeverDie said in nRF5 Bluetooth action!:
Epilog: I made the changes so that just prior to taking a measurement the sense pin is hwPinMode'd to an input pin, and then immediately after the measurement I disconnect it. Seems to be working, and without the usurious power drain I was experiencing previously. :)
Good news
So what is the current usage now when sleeping?@rmtucker said in nRF5 Bluetooth action!:
@NeverDie said in nRF5 Bluetooth action!:
Epilog: I made the changes so that just prior to taking a measurement the sense pin is hwPinMode'd to an input pin, and then immediately after the measurement I disconnect it. Seems to be working, and without the usurious power drain I was experiencing previously. :)
Good news
So what is the current usage now when sleeping?About 6ua on this particular Ebyte nRF52832. I'm pretty sure it would be higher on my other Ebyte nRF52832, though I haven't measured it again. Haven't tested any additional ones as of yet.
-
MY_HW_RTC->CC[0] = max((ms<<12 / 125), 2);
Should be:-
MY_HW_RTC->CC[0] = max(((ms << 12) / 125), 2));
-
MY_HW_RTC->CC[0] = max((ms<<12 / 125), 2);
Should be:-
MY_HW_RTC->CC[0] = max(((ms << 12) / 125), 2));
@rmtucker said in nRF5 Bluetooth action!:
MY_HW_RTC->CC[0] = max((ms<<12 / 125), 2);
Should be:-
MY_HW_RTC->CC[0] = max(((ms << 12) / 125), 2));Thank you. This was the result of merging some commits. I haven't seen I reversed that change. I had tested the code before merging some commits into one.
Actually I check the result of sleep(511999) and sleep(512001). When it's finished I fix that in MySensors.