OneWire pico w using Arduino IDE

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
User avatar
robert070
 
Posts: 3
Joined: Tue Jan 03, 2023 2:35 pm

OneWire pico w using Arduino IDE

Post by robert070 »

The pico board type is not defined in the OneWire.h header file (see below). Each section contains a few lines of gpio (board specific) defines -> mojo for the lower level DallasTemp code (I think).

The Arduino IDE is elegant for it's simplicity & I'm hoping I can stick with it for an educational environment. Any suggestions and/or condolences are appreciated.

Installed
Arduino IDE w/ board Raspberry Pi Pico W (rp2040)
Version: 2.0.3
Date: 2022-12-05T09:27:52.215Z
CLI Version: 0.29.0 [76251df9]

Copyright © 2023 Arduino SA

Installed the following via LIBRARY MANAGER
MAX31850 DallasTemp by Adafruit Version 1.14
MAX31850 OneWire by Adafruit Version 1.1.1

/home/x/Arduino/libraries/MAX31850_OneWire/OneWire.h:167:2: error: #error "Please define I/O register types here"
167 | #error "Please define I/O register types here"

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: OneWire pico w using Arduino IDE

Post by adafruit_support_carter »


User avatar
robert070
 
Posts: 3
Joined: Tue Jan 03, 2023 2:35 pm

Re: OneWire pico w using Arduino IDE

Post by robert070 »

Update & Observations

I modified OneWire.h to include the following defines for the pico chip:

[*]#define IO_REG_TYPE uint8_t
#define PIN_TO_BASEREG(pin) ( (volatile IO_REG_TYPE *) NULL )
#define PIN_TO_BITMASK(pin) ( (IO_REG_TYPE) pin )
#define IO_REG_ASM
#define DIRECT_READ(base, pin) digitalRead(pin)
#define DIRECT_WRITE_LOW(base, pin) digitalWrite(pin,0)
#define DIRECT_WRITE_HIGH(base, pin) digitalWrite(pin,1)
#define DIRECT_MODE_INPUT(base, pin) pinMode(pin,INPUT)
#define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin,OUTPUT)

**** Note -This looks like Arduino code as this is targeted to the pico using the Arduino IDE ****

These 'defines' were verified using a simple gpio. Once applied to OneWire.cpp, a call to OneWire.cpp:search() executes the search() -> reset() path. The sad news is that the chip appears to hang near the bottom of reset() somewhere in the block around line 159

noInterrupts();
DIRECT_MODE_INPUT(reg, mask); // allow it to float
delayMicroseconds(70);
r = !DIRECT_READ(reg, mask); // reads a high
interrupts();

Suggestions & Condolences are a appreciated.

User avatar
robert070
 
Posts: 3
Joined: Tue Jan 03, 2023 2:35 pm

Re: OneWire pico w using Arduino IDE

Post by robert070 »

The suggested defines posted Jan 6 work. However, there's a larger issue: the pico does not like the disabling / enabling of interrupts to assist with the strict timing of the screwy onewire interface. The system will hang.

A workaround was to comment out all interrupt enable/disables and to run the code on the idle second core.

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”