Blogger

Delete comment from: Ken Shirriff's blog

Seva said...

Had a Magsafe2 power supply fail and decided to poke around a bit and found your post. The failed one didn't work, seemed to have an internal short, but the replacement has a family 0x0085 and serial 0x001691df for a OneWire ID of 639213C61691DF85

Trying to reproduce the reading of the OneWire ID/Serial Number from the Magsafe2 and ran into strange problems, data seemed wrong on every read, but not quite garbage:

BBF2FFFDEABAEFAA 1101110101001111111111111011111101010111010111011111011101010101
BBEAFFFBAB75DF55 1101110101010111111111111101111111010101101011101111101110101010
BBEAFFFBD575DF55 1101110101010111111111111101111110101011101011101111101110101010
BBEAFFFBD575DF55 1101110101010111111111111101111110101011101011101111101110101010
BBEAFFFDD575DFA5 1101110101010111111111111011111110101011101011101111101110100101
3BF5FFFEEABAEFAA 1101110010101111111111110111111101010111010111011111011101010101
BBEAFFFBABEBDE55 1101110101010111111111111101111111010101110101110111101110101010
BBEAFFFBD575DF55 1101110101010111111111111101111110101011101011101111101110101010
BBEAFFFBD575DF55 1101110101010111111111111101111110101011101011101111101110101010
BBF4FFFDD575DF55 1101110100101111111111111011111110101011101011101111101110101010
3BF5FFFEEABAEFAA 1101110010101111111111110111111101010111010111011111011101010101
BBEAFFFBABEBBE2B 1101110101010111111111111101111111010101110101110111110111010100
BBEAFFFDD575DF55 1101110101010111111111111011111110101011101011101111101110101010
BBF2FFFDEABAEFAA 1101110101001111111111111011111101010111010111011111011101010101
BBEAFFFBAB75DF55 1101110101010111111111111101111111010101101011101111101110101010
5BF5FFFDD575EFAA 1101101010101111111111111011111110101011101011101111011101010101

Thought something was off with the timing, and even before confirming with the oscilloscope, on a whim doubled the values in the OneWire library as follows and the read started to work:

@@ uint8_t OneWire::read_bit(void)
noInterrupts();
DIRECT_MODE_OUTPUT(reg, mask);
DIRECT_WRITE_LOW(reg, mask);
- delayMicroseconds(3);
+ delayMicroseconds(6); // orig: 3
DIRECT_MODE_INPUT(reg, mask); // let pin float, pull up will raise
- delayMicroseconds(10);
+ delayMicroseconds(20); // orig: 10
r = DIRECT_READ(reg, mask);
interrupts();
- delayMicroseconds(53);
+ delayMicroseconds(106); // orig: 53
return r;
}

Confirming with oscilloscope, image:

https://imgur.com/a/dY5LR5e

CSV: https://pastebin.com/VMkQRpr4

The other issue I noticed that reset would sometimes work and sometimes fail. DS2314 data sheet https://datasheets.maximintegrated.com/en/ds/DS2413.pdf listed the min Trstl as 600us. The following change seems to make the reset() work all the time:

@@ uint8_t OneWire::reset(void)
noInterrupts();
DIRECT_WRITE_LOW(reg, mask);
DIRECT_MODE_OUTPUT(reg, mask); // drive output low
interrupts();
- delayMicroseconds(480);
+ delayMicroseconds(600); // orig: 480
noInterrupts();
DIRECT_MODE_INPUT(reg, mask); // allow it to float
delayMicroseconds(70);
r = !DIRECT_READ(reg, mask);
interrupts();
delayMicroseconds(410);
return r;
}

Nov 13, 2019, 11:06:09 PM


Posted to Teardown and exploration of Apple's Magsafe connector

Google apps
Main menu