Are you being squeezed by Supply Chain Shortages?
Is your chip no longer being made?
Is there a firmware bug
in your Chip?
Can't get the chip you need for your project?
Then Hack the Chip and make your own!
We built our product using Maxim's 1-Wire® to I2C DS28E17 bridge chip.
This allowed us to connect different I2C sensors, but discovered some issues.
With these issues we then designed the next product using the DS28E18.
During the design phase we discovered a major issue.
So we can't get the DS28E17.
The new DS28E18 does not work.
What can we do?
Hack the Chip!
To do this we need to first define all the requirements and find a suitable General Purpose Microcontroller. As it turns out the AVR ATTiny85 will meet our requirements, but it is going to be a challenge to get the high speed working. No worries we have a few programming tricks up our sleeves.
Feature | ATTiny85 | DS28E17 | DS28E18 |
---|---|---|---|
Available | Yes | No | Yes |
Cost 01/2024 | $1.50 | $5.01 | $1.57 |
Packaging | SOIC | TQFN | TDFN-CU |
Pins | 8 | 16 | 8 |
Power | 1.8-5.5V | 3V3 | 3V3 |
MHz | 20 | N/A | N/A |
Pins | 8 | 16 | 8 |
Flash | 8K | N/A | N/A |
SRAM | 512 Bytes | N/A | N/A |
EEPROM | 512 Bytes | N/A | N/A |
I2C | Yes | Yes | Yes |
I2C Clock Stretching | Yes | Yes | No |
UART | Software | No | No |
1-Wire® | Z-Wire | Yes | Yes |
Standard Mode | Yes | Yes | Yes |
Fast(Overdrive) Mode | High Speed | Yes | Yes |
GPIO Pins | 3 | None | 2 |
ADC Pins | 3 | None | None |
SPI | 3-Wire | No | 4-Wire |
Bit-Streaming | Yes | No | No |
Upgradable Firmware | Yes | No | No |
ROMID | 32 bit | 64 bit | 64 bit |
Programmable ROMID | Yes | No | No |
The ATTiny85 runs on a 20MHz clock, but this is not fast enough to process a Z-Wire Read 1 that has a falling and rising edge in 1us. The trick here is check and clear the pending rising edge interrupt in the previous falling edge interrupt.
We created a custom bootloader for the ATTiny85 to allow for firmware updates, but there is no reserved bootloader space and we need to use interrupts in the bootloader for the serial communications, and in the main program. To make this work on the ATTiny85 we are going to have to use a shared Interrupt Vector Table and to run the bootloader code the user will have to install a jumper.
Note: You must erase and write the bootloader IVT fast enough so that in the event of a power loss you will not brick the unit. The Z-Wire board has enough capacitance on it to only last a couple of ms before the voltage drops below the operational minimum of 1.8V.
void writeFlashPage(uint16_t address)
{
uint8_t i;
uint16_t data;
eeprom_busy_wait();
boot_page_erase(address);
boot_spm_busy_wait();
for (i = 0; i < SPM_PAGESIZE; i
+= 2) {
data = *(uint16_t*)&USI_Buffer[i];
boot_page_fill(address+i, data);
}
boot_page_write(address);
boot_spm_busy_wait();
}
So how do you have two different protocols exist on the same wire?
The 1-Wire® protocol is a master/slave protocol. A low Reset pulse from the master is followed by Presence Detect from the slave alerts the master that the slave device is listening. If a slave is detected by the master it then sends out a command that can be followed by data from the master or slave.
To coexist on the same wire all you have to do is have the master send out a different length reset pulse and/or different command.
Z-Wire uses a 32-bit Programmable Address instead of the 1-Wire® 64-bit ROM address. Every time the device is selected only 32-bits of address data needs to be sent resulting in shorter and faster communication times. Searching time is also significantly improved.
After carefully validating and testing all the requirements we now have created a replacement for the DS28E17 with new and improved features!
Feature List
1-Wire is a registered trademark of Maxim Integrated Products, Inc.