How to wake on TAMP1 (PC13)..?
How to wake on TAMP1 (PC13)..?
Hi all,
Anyone with working code to wake a PYBD from Standby using PC13? I have been hacking at this on and off for a while, but I'm clearly missing something in the 1954-page datasheet
Appreciate any insight!
Cheers,
--Nick
Anyone with working code to wake a PYBD from Standby using PC13? I have been hacking at this on and off for a while, but I'm clearly missing something in the 1954-page datasheet
Appreciate any insight!
Cheers,
--Nick
Re: How to wake on TAMP1 (PC13)..?
Well, a bucket of coffee this morning and a fresh look and it was just me being stupid. Couple of registers have changed names that I managed to miss several times through... I was looking for something far more complicated and missed the simple stuff
For example, to make Peter's upower library Tamper() work on the PYDB, just rename the registers...
PWR_CR -> PWR_CSR2
RTC_TAFCR -> RTC_TAMPCR
For example, to make Peter's upower library Tamper() work on the PYDB, just rename the registers...
PWR_CR -> PWR_CSR2
RTC_TAFCR -> RTC_TAMPCR
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: How to wake on TAMP1 (PC13)..?
Adapting that library to support Pyboard D is on my (very long) TODO list. I wonder how many other names need to be changed.
I have amended upower.py to detect a Pyboard D and make those changes if you'd like to try it.
I have amended upower.py to detect a Pyboard D and make those changes if you'd like to try it.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: How to wake on TAMP1 (PC13)..?
Just a couple of small things by the looks of it -
An oldie but a goodie
Looks like X18 is removed from the board definitions (I'm just using cpu.C13).
My application has the line going high to trigger the interrupt (level=1). I changed the pin setup to PULL_DOWN, and in addition to your code I needed to disable the tamper pullup/precharge (set RTC_TAMPCR bit 15). Pg 1167:
--Nick
An oldie but a goodie
Code: Select all
>>> import upower
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "upower.py", line 20, in <module>
AttributeError: type object 'board' has no attribute 'USB_VBUS'
Code: Select all
>>> tamper=upower.Tamper()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "upower.py", line 34, in getinstance
File "upower.py", line 113, in __init__
AttributeError: type object 'board' has no attribute 'X18'
Also specific to my application, I'm using the Tamper line as a general wake-up interrupt, not a security "tamper" mechanism, so I did not want the backup registers to be deleted. I needed to set RTC_TAMPCR bit 17 to achieve this. Pg 1167:Bit 15 TAMPPUDIS: RTC_TAMPx pull-up disable
This bit determines if each of the RTC_TAMPx pins are precharged before each sample.
0: Precharge RTC_TAMPx pins before sampling (enable internal pull-up)
1: Disable precharge of RTC_TAMPx pins.
Hope this is useful.Bit 17 TAMP1NOERASE: Tamper 1 no erase
0: Tamper 1 event erases the backup registers.
1: Tamper 1 event does not erase the backup registers.
--Nick
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: How to wake on TAMP1 (PC13)..?
Very useful indeed, Nick. Thank you. Clearly the behaviour for level 1 was incorrect for Pyboard 1.x too. I've pushed an upgrade to address the points you've made.
It seems that the erasure of backup registers is specific to the Pyboard D: chip data for the V1.x assigns a different meaning to bit 17 so I've made that Pyboard D specific.
I wonder what else has been broken on the Pyboard D: which other features of upower.py have you used? Have you measured the current draw when in low power mode?
It seems that the erasure of backup registers is specific to the Pyboard D: chip data for the V1.x assigns a different meaning to bit 17 so I've made that Pyboard D specific.
I wonder what else has been broken on the Pyboard D: which other features of upower.py have you used? Have you measured the current draw when in low power mode?
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: How to wake on TAMP1 (PC13)..?
Hi Peter,
Sorry I thought I replied to this at the time but clearly I imagined it.
I haven't tried the other features/modes of the upower library sorry. I hope to get the opportunity to give it a thorough run through at some stage but there always seems to be something urgent requiring attention first. I will see if I can find a moment to throw a fresh PYBD on the bench and test current draw (my dev unit has had a hard life and now appears to baseline at ~35mA no matter what is shut down...!)
--Nick
Sorry I thought I replied to this at the time but clearly I imagined it.
I haven't tried the other features/modes of the upower library sorry. I hope to get the opportunity to give it a thorough run through at some stage but there always seems to be something urgent requiring attention first. I will see if I can find a moment to throw a fresh PYBD on the bench and test current draw (my dev unit has had a hard life and now appears to baseline at ~35mA no matter what is shut down...!)
--Nick
Re: How to wake on TAMP1 (PC13)..?
I am using a PYB with V1.14.
I am able to wake up using PA0 if I add the code,
stm.mem32[stm.PWR + stm.PWR_CSR] |= 1 << 8 # enable WKUP pin on PA0 (X1)
However, I'm not having much luck using PC13 to wake up on a rising edge. I have looked at Peter's upower.py program and tried setting the tamper 1 enable, and disable pullups and precharge.
stm.mem32[stm.PWR + stm.RTC_TAFCR] |= 3 | (1<< 15) # Tamper 1 disable pullups and precharge
Does upower support PC13 on the PYB V11? Or is it only for the PYBD?
Thanks,
Brad
I am able to wake up using PA0 if I add the code,
stm.mem32[stm.PWR + stm.PWR_CSR] |= 1 << 8 # enable WKUP pin on PA0 (X1)
However, I'm not having much luck using PC13 to wake up on a rising edge. I have looked at Peter's upower.py program and tried setting the tamper 1 enable, and disable pullups and precharge.
stm.mem32[stm.PWR + stm.RTC_TAFCR] |= 3 | (1<< 15) # Tamper 1 disable pullups and precharge
Does upower support PC13 on the PYB V11? Or is it only for the PYBD?
Thanks,
Brad
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: How to wake on TAMP1 (PC13)..?
I have recently updated the upower library to support Pyboard D.
The Pyboard 1.1 supports wakeup on X1 and X18/C13, the latter being facilitated by the Tamper class. The pin has special properties in Tamper mode as described in the docs.
The Pyboard D also supports those pins.
Via the new version of upower the Pyboard D also supports these pins but you will need a daily firmware build to achieve this.
The Pyboard 1.1 supports wakeup on X1 and X18/C13, the latter being facilitated by the Tamper class. The pin has special properties in Tamper mode as described in the docs.
The Pyboard D also supports those pins.
Via the new version of upower the Pyboard D also supports these pins but you will need a daily firmware build to achieve this.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: How to wake on TAMP1 (PC13)..?
Thank you!
Brad
Brad