Smallest micro with i2c master interface - Page 1
Forum section: electronics / general

author: bentomo
author_rank: Contributor
timestamp: July 26, 2016, 06:32:57 pm
content: Hey guys, I'm planning on designing a new battery charger and DC-DC converter using an all in one chip from TI. I believe I'll be using thehttp://www.digikey.com/product-detail/en/texas-instruments/TPS65090ARVNR/296-40864-1-ND/5178741however to avoid lots of external components it uses i2c for various programming.Basically, I want to program the smallest i2c master controller I can find so the PMIC will output 3 buck outputs at 3.3v, 1.15v, 1v, and a 5v ldo reference on startup, and manage/charge a 2 cell 7.4v lithium ion pack or 3 cell 11.1v lithium ion pack. I've heard of using a USI module as an i2c master using a library, but I don't think that would fit on something as small as an attiny4 sot 23-6.The only other two features I need is a button debounce to enable the PMIC output voltages(instead of using an on-off switch), and one ADC pin to measure the battery voltage under load for low battery detection. (cheap coulomb counting)My biggest concern is footprint size and part count, as I build all my circuits by hand and I typically make them in a 15mm x 30mm board size. (Tiny boards I know) My last board I designed had a charger ic and a separate buck regulator for each voltage and I ended up with 95 components overall. (and a cost of $25+ just for all the IC'sPlease let me know your thoughts and what controller you guys would recommend.Thanks!!This will be my first i2c related project as I've mostly just used the arduino environment for microcontroller projects in the past. Somethin easy like the arduino IDE would be nice, but obviously the bootloader would take up way too much space so I'm fine with just doing straight C.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: July 26, 2016, 06:39:05 pm
content: I2C is easy enough to bit-bash, so if you need small, pretty much anything will do

author: bentomo
author_rank: Contributor
timestamp: July 26, 2016, 06:47:17 pm
content: So basically lock the clock and write to the SDA line?That sounds easy enough. Unfortunately the ATTiny 4 only has .512Bytes of flash so I'll need to be logically efficient. I'll look into that.

author: Signal32
author_rank: Frequent Contributor
timestamp: July 26, 2016, 06:47:36 pm
content: You can go with the supersized 2x3mm PIC12LF1552http://www.digikey.com/product-detail/en/microchip-technology/PIC12LF1552-I-MU/PIC12LF1552-I-MU-ND/4215272Or the reasonably small 1.56x1.4 ATTINY20-UUR.http://www.digikey.com/product-detail/en/atmel/ATTINY20-UUR/ATTINY20-UURTR-ND/3775119Both have I2C. There are also options in-between.

author: nctnico
author_rank: Super Contributor
timestamp: July 26, 2016, 07:18:40 pm
content: Quote from: bentomo on July 26, 2016, 06:47:17 pmDo not forget to implement I2C clock stretching (let the clock go high and wait until it really is high)! Some I2C slave devices may need more time to respond and will use clock stretching to achieve that. Also have time-outs so the device doesn't hang completely when an I2C device isn't responding at all.

author: Jeroen3
author_rank: Super Contributor
timestamp: July 26, 2016, 07:32:07 pm
content: The LPC812M101JTB16 is only 2.5 x 3.2 x 0.5 mm. You can run mbed (arduino competitor for arm) on lpc800 if I recall correctly.Or an STM32L031 in one of their wlcsp's or maybe even UFQFPN28 which is small already.

author: bentomo
author_rank: Contributor
timestamp: July 26, 2016, 07:40:08 pm
content: This one looks niftyhttp://www.digikey.com/product-detail/en/microchip-technology/PIC16LF18313-I-RF/PIC16LF18313-I-RF-ND/5401256But I think I would need to buy a $45 PICkit 3 to be able to program it, not a cheap usb to serial converter I'm used to with Atmel.

author: MosherIV
author_rank: Super Contributor
timestamp: July 26, 2016, 07:56:01 pm
content: HiHave a look at STM8 as well, they come in surface mount DIL, have ADC and I2C peripherals built in.ST do some really cheap dev boards to prototype on, board has built in programmer.

author: Howardlong
author_rank: Super Contributor
timestamp: July 26, 2016, 08:19:18 pm
content: Quote from: bentomo on July 26, 2016, 07:40:08 pmA Curiosity board would program it.PIC10F is my weapon of choice for these simple initialising jobs, in SOT23, but it's a bit banging job.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: July 26, 2016, 09:07:02 pm
content: Quote from: bentomo on July 26, 2016, 07:40:08 pmThere are plenty of cheap PicKit 3 clones out there

author: dannyf
author_rank: Super Contributor
timestamp: July 26, 2016, 09:16:30 pm
content: There are some sot23 mcus.

author: Monkeh
author_rank: Super Contributor
timestamp: July 26, 2016, 09:22:22 pm
content: Quote from: bentomo on July 26, 2016, 07:40:08 pmI'll see your 79 cent PIC and raise you a 44 cent EFM8:http://www.digikey.com/product-detail/en/silicon-labs/EFM8BB10F2G-A-QFN20/336-3162-5-ND/5115719UART bootloader built in - assuming you get one made this year, anyway.Never actually used one, though. Been meaning to get my hands on a couple.

author: Cixelyn
author_rank: Newbie
timestamp: July 26, 2016, 11:48:21 pm
content: The EFM8s are actually quite nice. I'm currently using the EFM8UB1 in aprojectand I picked it specifically for its tiny size (3mm x 3mm QFN) due to board space constraints. For simple initialization, I don't think you can go wrong picking one of those parts, especially since you'll get hardware i2c support. And it's practically the same size as one of those SOT23-6 MCUs.

author: Jeroen3
author_rank: Super Contributor
timestamp: July 27, 2016, 05:24:57 am
content: Quote from: bentomo on July 26, 2016, 07:40:08 pmThat won't work if you buy an empty chip from Digikey. You will need a programmer. Or you need to buy a chip with rom bootloader.

author: Howardlong
author_rank: Super Contributor
timestamp: July 27, 2016, 05:57:15 am
content: Quote from: Jeroen3 on July 27, 2016, 05:24:57 amYou can jury rig TTL level serial ports to program PICs, I did one for a product many years ago, but it's not supported by IDEs, and what with this new fangled USB-serial port rubbish (rather than a real hardware serial port) getting the handshake lines to behave in a deterministic way and properly generate the programming signals has proved somewhat difficult.

author: Mechatrommer
author_rank: Super Contributor
timestamp: July 27, 2016, 10:30:40 am
content: pic10f206 or attiny10, the smallest hand solderable. public i2c library doesnt fit? thats why we built our own, not complete, but workable for a particular task.

author: JPortici
author_rank: Super Contributor
timestamp: July 27, 2016, 10:46:04 am
content: If you go on microchip direct there is a selection of PICs that can be bought and pre-programmed with the hex file you provide, will it be the final firmware or maybe better a bootloaderQuote from: mikeselectricstuff on July 26, 2016, 09:07:02 pmThat doesn't really work and there are many chances that every OS/MPLABX Update will breakAlso, there is a discount on all programmers till the end of the month

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: July 27, 2016, 12:36:43 pm
content: Quote from: JPortici on July 27, 2016, 10:46:04 ampretty much all PICs can be preprogrammed & marked - cost is very low, pennies for the smaller parts MOQ 150 from memoryQuoteI've had a couple of the "kit 3.5" clones and they are fine.

author: nctnico
author_rank: Super Contributor
timestamp: July 27, 2016, 01:03:17 pm
content: Quote from: Jeroen3 on July 27, 2016, 05:24:57 amWhich is why the NXP LPC800 parts are much easier to work with. You can program these from a serial port and 2 handshake lines.

author: bentomo
author_rank: Contributor
timestamp: July 27, 2016, 01:47:54 pm
content: Quote from: nctnico on July 27, 2016, 01:03:17 pmISP would be really nice, in facts that what I've used on some of my previous boards. Simply burn a bootloader and expose an RX and a TX line.

author: nctnico
author_rank: Super Contributor
timestamp: July 27, 2016, 02:13:49 pm
content: Quote from: bentomo on July 27, 2016, 01:47:54 pmAll NXP microcontrollers have a serial port bootloader.

author: tszaboo
author_rank: Super Contributor
timestamp: July 27, 2016, 03:29:33 pm
content: Quote from: mikeselectricstuff on July 26, 2016, 06:39:05 pmNot to mention that with bit banging you can save two pull up resistors, so that is another 2 cents there, not to mention board space. A SOT23 PIC or Atmel is all you need.

author: nctnico
author_rank: Super Contributor
timestamp: July 27, 2016, 03:43:57 pm
content: Quote from: NANDBlog on July 27, 2016, 03:29:33 pmNo you can't. I2C relies on using the pull-up resistors.

author: tszaboo
author_rank: Super Contributor
timestamp: July 27, 2016, 04:15:09 pm
content: Quote from: nctnico on July 27, 2016, 03:43:57 pmSo you use the built in pullup resistors, which are 95% disabled if you use hardware I2C. Also, clock stretching is something which rarely ever used, so why bother.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: July 27, 2016, 04:33:28 pm
content: Quote from: nctnico on July 27, 2016, 03:43:57 pmFor master, assuming no clock stretching, you can drive SCL high & low, eliminating one pullup.You can use internal pullups for SDA, but may get a bit slow if there's any significant track length.If you have unused pins, you could parallel them to get more pullup strength

author: nctnico
author_rank: Super Contributor
timestamp: July 27, 2016, 04:56:50 pm
content: Quote from: NANDBlog on July 27, 2016, 04:15:09 pmDon't underestimate the use of clock stretching! A while ago I diagnosed a problem for a customer. A microcontroller (with bit-banging I2C and no clock stretching support) queried an I2C slave chip regulary but only once in a while (=one hour or so) this went wrong. It turned out the I2C slave chip needed some more time every now and then so 0.2% of the I2C transactions failed. Unfortunately the use of clock stretching or delays was not specified anywhere in the datasheet. In other words: manufacturers implicitely assume I2C busses support clock stretching.

author: tszaboo
author_rank: Super Contributor
timestamp: July 27, 2016, 05:05:24 pm
content: Quote from: nctnico on July 27, 2016, 04:56:50 pmCare to share, what was the I2C slave, which used it? At least type?

author: nctnico
author_rank: Super Contributor
timestamp: July 27, 2016, 08:45:35 pm
content: I don't recall the exact type but it was a battery charge gauge chip from TI.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: July 27, 2016, 11:10:43 pm
content: Quote from: nctnico on July 27, 2016, 08:45:35 pmWonder if it's actually a preprogrammed MCU, which would explain the need for stretching - I recently fond that the Atmel AT42QT1070 capsense chip is just a preprogrammed ATTinysomething - first time I'd ever seen anything use clock stretching.

author: tszaboo
author_rank: Super Contributor
timestamp: July 28, 2016, 08:18:53 am
content: Quote from: mikeselectricstuff on July 27, 2016, 11:10:43 pmMost I2C/SPI GPIO extenders from Microchip are programmed micros. Also, I suspect the USB-UART and other converters are just preprogrammed and marked PICs. But I suspect other manufacturers are doing the same. Maybe not to the extent, where you can reprogram it.