-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nRF52840 - SPIM3 not working if VBUS not powered when reset #5233
Comments
Just as an exercise, I verified that the same issue occurs with an rfm9x breakout board instead of the featherwing. |
I just tested this on another SPI device (BMP390) to see if this is a general issue. I used the following bit of code:
It works fine on USB power, but on battery it also fails:
Hence it seems to not be related to the RFM9x at all. Tested it on 7.0.0rc1 |
@mrdalgaard Thanks -- That was next on my todo list! |
This issue might be related: This could also be related, but have not tested with a capacitor yet: SPIM3 does look to have a history of issues when searching for solutions. |
Interesting -- the first link does appear to be the same issue
|
An additional observation -- If I power it up via USB, then disconnect the USB and leave it on battery power, it continues to operate normally. The issue only occurs if it is powered up or RESET when in battery power. |
Yes, and since the person in the first link does not seem to be using CircuitPython, it would seem to be a problem with the hardware, or the bootloader, which is in common. |
SPIM3 has a number of errata. We have implemented a RAM workaround to get it to work reliably. But I had not heard of this VBUS issue until now. I will look at this further in a few days and probably ask Nordic about it. |
I just remembered one thing that may help, when vbus is detected, usb will auto enable the hfclk() https://github.com/hathach/tinyusb/blob/master/src/portable/nordic/nrf5x/dcd_nrf5x.c#L1001 I am not sure it could help, maybe just try to plainly enable hfclk() to see if it has any impact. |
@hathach That is very interesting, I'll try that! I note the examples above all don't use BLE, which would turn on HFCLK for radio purposes. |
I partly reproduced this, but with the latest build ( import board
#import _bleio
spi = board.SPI()
spi.try_lock()
data = bytes([0x79] * 100)
while True:
spi.write(data) I was originally testing (by mistake) with some random earlier 7.0.0 build, but when I tried the latest I tried physically unplugging the battery to make sure it would work from a cold start as well as a reset. Could you folks try again with an "Absolute Newest" build? If you don't have an oscilloscope or logic analyzer, you can just monitor the SCK pin with an LED and it should be dimly lit. You can increase the size of |
Just to clarify, did you start from power off when trying with the LiPo? It will keep running if initially powered via USB then unplugged. I'll try it in an hour or so. |
I tried to reproduce the problem, using my currently running code, by just commenting out the workaround. This bit of code will run ok:
While this will fail:
What does the watchdog change that makes this work? Otherwise i'm seeing the same issue as on 7.0.0b0 - Currently testing with: |
Adding |
Yes, both from a reset-button push, and from plugging the battery into an unpowered board. |
I just tried my previous code and it behaves the same as before -- work on USB, not on LiPo
code.py
|
Can you try my simple example as well? |
@dhalbert I tried your code and it shows SPI Activity (with Salea) under both LiPo and USB |
but switching to my code -- I see nothing under LiPo Power.... |
More mentions of apparently the same problem: https://forums.adafruit.com/viewtopic.php?f=62&t=188798 (user encountering this) |
I'm still seeing this issue with recent NRF52840 boards using the Adafruit core. Could someone give me an example of Arduino code that would implement the workaround, or is there a better workaround at this point? Thanks! |
See this Forum thread for the details:
https://forums.adafruit.com/viewtopic.php?f=57&t=182604&p=887344#p887344
Summary:
with an RFM9x featherwing mounted on a nRF52840, all works normally when powered vis USB, but when powered via a LiPo battery, the rfm9x fails its version check.
The OP found a workaround:
create a dummy SPI instance before creating the real SPI instance that is fed to the rfm9x init.
This appears to force the nRF52840 to use a different SPIM and it works. It is not clear why....
This problem is not present on M4 or esp32S2 boards.
The text was updated successfully, but these errors were encountered: