Jump to content

OneWire library resets pinmode of pin 3 (Rx)

Recommended Posts

I've been working on a project that uses both OneWire and Serial protocols. I realized that I could send serial data from the MSP430FR4133 launchpad to the computer and use the OneWire to read temperature data. I could not however send serial data from the computer to the launchpad when using OneWire. If OneWire was not used, serial data went both ways without a problem indicating an incompatibility between the OneWire and Serial libraries.


I tracked it down to a call to ds.reset() as the problem. Looking at the source for the OneWire.reset() function in OneWire.cpp, there was a suspicious call to pinMode and digitalWrite:

uint8_t OneWire::reset(void)
	pinMode(3, OUTPUT);  //why is this here?
	digitalWrite(3, HIGH);  //why is this here?
	IO_REG_TYPE mask = bitmask;
	volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg;
	uint8_t r;
	uint8_t retries = 125;

Why was OneWire.reset() directly setting pin 3 (UART Rx) mode and value? Looking at Paul Stoffgren's site (http://www.pjrc.com/teensy/td_libs_OneWire.html), the suspicious lines were not there. I commented out the offending lines and now OneWire and Serial receive both work fine. I looked at the OneWire library for MSP432 and LM4F; they too have the same bug/feature. Did not check other architectures.

Link to post
Share on other sites
  • 2 weeks later...
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...