chipKIT® Development Platform

Inspired by Arduino™

PIC32MZ and OneWire

Created Wed, 24 Jun 2015 20:33:56 +0000 by mindtheory


mindtheory

Wed, 24 Jun 2015 20:33:56 +0000

Hi guys,

I'm trying to get OneWire working with a ChipKIT Wi-Fire (PIC32MZ).

The registers aren't defined in the OneWire.h header.

I'm lost as to where I can find the info to add these register definitions. Does anyone know what they might be or where to look for them?

Cheers!

// Platform specific I/O definitions

#if defined(AVR) #define PIN_TO_BASEREG(pin) (portInputRegister(digitalPinToPort(pin))) #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) #define IO_REG_TYPE uint8_t #define IO_REG_ASM asm("r30") #define DIRECT_READ(base, mask) ((((base)) & (mask)) ? 1 : 0) #define DIRECT_MODE_INPUT(base, mask) (((base+1)) &= ~(mask)) #define DIRECT_MODE_OUTPUT(base, mask) (((base+1)) |= (mask)) #define DIRECT_WRITE_LOW(base, mask) (((base+2)) &= ~(mask)) #define DIRECT_WRITE_HIGH(base, mask) ((*(base+2)) |= (mask))

#elif defined(PIC32MX)

#define PIN_TO_BASEREG(pin) (portModeRegister(digitalPinToPort(pin))) #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) #define IO_REG_TYPE uint32_t #define IO_REG_ASM #define DIRECT_READ(base, mask) ((((base+4)) & (mask)) ? 1 : 0) //PORTX + 0x10 #define DIRECT_MODE_INPUT(base, mask) (((base+2)) = (mask)) //TRISXSET + 0x08 #define DIRECT_MODE_OUTPUT(base, mask) (((base+1)) = (mask)) //TRISXCLR + 0x04 #define DIRECT_WRITE_LOW(base, mask) (((base+8+1)) = (mask)) //LATXCLR + 0x24 #define DIRECT_WRITE_HIGH(base, mask) ((*(base+8+2)) = (mask)) //LATXSET + 0x28

#else #error "Please define I/O register types here" #endif


majenko

Wed, 24 Jun 2015 22:22:06 +0000

You can try changing the

#elif defined(__PIC32MX__)

to just

#elif defined(__PIC32__)

since the IO registers should be the same on the MZ as they are on the MX.