Which AVR IC would you recommend for my project?

Hello guys,

I'm planning on doing a battery management PCB, based on Arduino/AVR architecture, specially due to its ease in programming and communicating with peripherals. There are dozens of AVR micro-controllers available, both from the ATTiny lineup and the ATMega lineup. But i don't have a lot of knowledge on those, and would like some recommendations of yours.

These are the features the IC should have:
Separate I2C and SPI pins, as i need to use both protocols at the same time
EEPROM memory (just a tiny little bit is already enough)
Have the smallest number of pins possible, and low power comsumption, as it is a very compact project
Don't need to have great amount of programming memory, as the program to be uploaded should be relatively simple

Currently i'm thinking on ATTiny42, the only problem is that it shares its I2C and SPI pins, and altough i think it should be possible to use them together, it is not ideal, because it would probably require extra components like transistors

Also, basically any ATMega meets the requirements i need, but the smallest one has 28 pins, which is too much, i would use like 6 or 7 only.

So, what do you guys think? Any suggestions? Maybe something out of the AVR lineup that is still programmable via Arduino IDE?

Thank you in advance!!!

What about ATTiny841?

14 pins, 11 I/O pins, hardware SPI. I2C master is by software implementation (as there's no hardware I2C master), I2C slave is done in hardware. Supported by my ATTinyCore (see sig).

If this is a low volume board, silicon cost (and size) isn’t a factor and trying to shove it in the smallest package, in both physical size and capacity is not a good use of your time.

If you must squeeze things into small packages - and you don’t have experience with the AVR family, my suggestion would be to start development on something larger than you expect you’ll need, like the atMega328. A Nano or Pro Mini board is an excellent starting point. Get it working first! Then optimize.

Maybe it will fit in an 4k part using hardware SPI and bit banging the i2c. There will be options that you can explore when it’s working and you know the memory requirements. You can test any and all possibilities on the ‘328 and then recompile for your target processor, load and go.

IMO, using the approach of first picking a processor and then making code fit is putting the cart in front of the horse. There are times a developer must do that but this doesn’t appear to be one of those times. It’s unlikely you’d be here on this fourm if it was.

Well, in my case, DrAzzy, what i need to do is use I2C slave and SPI master. Doesn't the AtTiny841, share the same pins for I2C an SPI? I'm almost sure it does

WattsThat thank you! I'm just planning on what am i going to do for next few days, i can't actually make things work right now (or test things) because i have other impediments, such as parts to arrive and other parts of the project to be accomplished. So as you said, i am "putting the cart in front of the horse", but my ideia is just to have an approach on feasibility, and gather more knowledge about those processors

Spi and UART are remappable on t841.
I can’t quite tell if you can use a UART, spi, and I2c all at the same time on the 14pin chip. I don’t think you can run all 4 advertised serial ports.

You might be better off learning to deal with a smaller 28/32 pin package, than trying to find a chip with fewer pins... the qfn28 is smaller than an soic14, I think.

westfw:
Spi and UART are remappable on t841.
I can’t quite tell if you can use a UART, spi, and I2c all at the same time on the 14pin chip. I don’t think you can run all 4 advertised serial ports.

I don't need to use UART, only slave I2C and master SPI. The ATtiny841 seems to be useful for this purpose, i'm going to read its datasheet to see if it is actually doable.

westfw:
You might be better off learning to deal with a smaller 28/32 pin package, than trying to find a chip with fewer pins... the qfn28 is smaller than an soic14, I think.

Indeed this looks like a resonable solution, tough i don't know if it would more of a challenge to program a PIC rather than an AVR. But i'm thinking maybe using an ATmega chip that comes in one of those super compact smd packaging .

You could alsogo for an ATmega48, ATmega8 or ATmega88 in a QFN package. Cheap if you source them from the right source, excellent support through MiniCore.

Smug:
Well, in my case, DrAzzy, what i need to do is use I2C slave and SPI master. Doesn't the AtTiny841, share the same pins for I2C an SPI? I'm almost sure it does

You can use the REMAP register to change the pins that SPI is on to a different set of pins; see the datasheet SPI chapter. Not only that, the version of SPI library included with my core is smart enough to check the status of this register when setting the pin modes of the SPI pins to get the right ones (just set REMAP before initializing SPI)

westfw:
Spi and UART are remappable on t841.
I can’t quite tell if you can use a UART, spi, and I2c all at the same time on the 14pin chip. I don’t think you can run all 4 advertised serial ports.

Per datasheet, there are two UARTs, not 4. You can change which pair of pins they use. See the UART section of the datasheet for more info.

I think you can use all of them at once? Would have to study the datasheet.

there are two UARTs, not 4.

Yes, I mean four total serial interfaces - 2 UARTs, 1 SPI, 1 TWI...

I think you can use all of them at once?

It looks like you can get UART0(alt), SPI(alt), and TWI all working at once, but TWI and UART1 (neither of which is changeable) conflict with each other.