Skip to content
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

BLE 33 - .overlay updates, enable Wire1, pins match MBED, change analogRead to 12 bit #50

Merged
merged 3 commits into from
Jan 29, 2025

Conversation

KurtE
Copy link

@KurtE KurtE commented Jan 25, 2025

Resolves: #49 #48

Note: @mjs513 has a version of the wire scanner that works with this.
however Wire object takes a while to scan unless external PU resistors are connected to SCL/SDA pins.
The sketch also turns on the Wire1 PU resistors and enables the Wire1 objects, using D32 and D33 below.
These pins are shown on the schematics for the different versions of the Nano 33 BLE boards.

Also @mjs513 found an interesting web page:
https://github.com/saltyJeff/zephyr_arduino_nano_33_ble/blob/main/src/init_arduino_style.c
Which also confirmed the need to initialize the two pins on Wire1 for the devices to work.

Extra pins:

 					<&gpio0 24 0>,	/* D22 LED R */
  					<&gpio0 16 0>,	/* D23 LED G */
  					<&gpio0 6 0>,	/* D24 LED B */
  					<&gpio1 9 0>,	/* D25 LED PWR */
  					<&gpio0 19 0>,	/* D26 INT APDS */
  					<&gpio0 17 0>,	/* D27 PDM PWR */
  					<&gpio0 26 0>,	/* D28 PDM CLK */
  					<&gpio0 25 0>,	/* D29 PDM DIN */
  					<&gpio0 14 0>,	/* D30 SDA2 */
  					<&gpio0 15 0>,	/* D31 SCL2 */
  					<&gpio1 0 0>,	/* D32 I2C_PULL */
  					<&gpio0 22 0>;	/* D33 VDD_ENV_ENABLE */

Note some of these pins are important to enable Wire1 to work. Including enabling power to the sensors as well as to enable the Pull up resistors on the Wire1 object.

Added Wire1 object to the list of wire bojects.
Set default clock-frequency on the two I2C objects, like the GIGA has defined.

Also changed the ADC conversion resolution for all of the channels from 10 bits to 12, as that is I believe the maximum the device supports. So when we pull in the PR for analogRead it should then map down to the resolution the user chooses with analogReadResolution call.

@mjs513
Copy link

mjs513 commented Jan 25, 2025

Between @KurtE and myself we tested on
Nano 33 sense BLE V1
Nano 33 sense BLE V2
and
Nano 33 BLE.

Only remaining issue is that setting a clock to 100Khz/I2C_SPEED_STANDARD remains flaky - see issue for more details

@KurtE
Copy link
Author

KurtE commented Jan 28, 2025

@facchinm - I added the turn on FPU in this PR as well.
Fixed a lot of weird crashes!

KurtE and others added 3 commits January 29, 2025 09:45
…ogRead to 12 bit

Extra pins:
```
 					<&gpio0 24 0>,	/* D22 LED R */
  					<&gpio0 16 0>,	/* D23 LED G */
  					<&gpio0 6 0>,	/* D24 LED B */
  					<&gpio1 9 0>,	/* D25 LED PWR */
  					<&gpio0 19 0>,	/* D26 INT APDS */
  					<&gpio0 17 0>,	/* D27 PDM PWR */
  					<&gpio0 26 0>,	/* D28 PDM CLK */
  					<&gpio0 25 0>,	/* D29 PDM DIN */
  					<&gpio0 14 0>,	/* D30 SDA2 */
  					<&gpio0 15 0>,	/* D31 SCL2 */
  					<&gpio1 0 0>,	/* D32 I2C_PULL */
  					<&gpio0 22 0>;	/* D33 VDD_ENV_ENABLE */
```
Note some of these pins are important to enable Wire1 to work.  Including enabling power to the sensors
as well as to enable the Pull up resistors on the Wire1 object.

Added Wire1 object to the list of wire bojects.
Set default clock-frequency on the two I2C objects, like the GIGA has defined.

Also changed the ADC conversion resolution for all of the channels from 10 bits to 12, as that is I believe
the maximum the device supports.  So when we pull in the PR for analogRead it should then map down to
the resolution the user chooses with analogReadResolution call.
A lot of the crashes were happening because of this.

More details in issue arduino#57
@facchinm
Copy link
Member

@KurtE I refactored your commits a bit to have only one loader rebuild and pushed zephyrproject-rtos/zephyr#84675 to our fork while waiting for upstream to apply it ( see https://github.com/arduino/zephyr/tree/arduino_core_merge_4.0.99 ).
After the CI completes, we should have all the needed fixes applied for nano33ble

@facchinm facchinm merged commit 78a9a62 into arduino:arduino Jan 29, 2025
4 checks passed
@KurtE KurtE deleted the nano33_overlay branch January 29, 2025 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nano 33 Sense v2: I2c Scanner running for Wire only acting strangely
3 participants