Does 32 bit variables work with gcc? I have feeling that 32 bit calculations have some problems?

## ATtiny 13 A & 32 bit variables?

Author

Message

Quote:

Of course they do.Does 32 bit variables work with gcc?

Quote:

I'm not sure why you would say that. Certainly on the tiny13 you will have to be careful how many you use since it only has 64 bytes of ram.
I have feeling that 32 bit calculations have some problems?

Level: Moderator

Joined: Mon. Jul 18, 2005

Posts: 102107 View posts

Location: (using avr-gcc in) Finchingfield, Essex, England

Of course they work but beware the integer promotion rules of C and the fact that the natural int size of AVR is just 16 bits so intermediate calculation results can often overspill the implied -32768..+32767 integer range of integer constants.

Try appending some "UL"s to any numeric constants involved in calculating a 32bit result and this will promote the whole calculation to 32bit.

Level: Moderator

Joined: Wed. Mar 28, 2001

Posts: 30295 View posts

Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweis, but plenty of Corona beer)

Quote:

Yes, whether you have enough ram in the T13 it's another story. Maybe you can add 2 32 bit numbers together. :?
Does 32 bit variables work with gcc?

Quote:

Yes, whether you have enough ram in the T13 it's another story. Maybe you can add 2 32 bit numbers together.

LOL--Reminds me of a past project creating an industrial counter. The app was fairly simple so the first choice was a similar "SRAM challenged" AVR model. The kicker was a 40-bit counting requirement. I got it to fit--barely. Nowadays it would be easier. Back then there weren't as many AVR models, and each was "several dollars". Nowadays it is "less than a couple dollars" for e.g. Mega48 and "less than a dollar" to move up to e.g. Mega88 (with a whopping 1K of SRAM!).

Lee