Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

max bit variable in AVR

Status
Not open for further replies.

tariq70

New Member
hi I'm using AVR codevision after defining 16 bit variable codevision shows this error :
too many global/static 'bit' variables
Does bit variables are limited in AVR?or they are just limited in codevision?or it's something else?
 
Last edited:
My guess would be codevision as the avr doesn't care if you access all the available ram as bits. How many do you have?
Is codevision similar to C and can you have a Union?

Mike.
 
All I know is... Pic assembly only allows bit access to a few ram locations... AVR may be the same... If your compiler is the GNU derivative ( I think it is )

You can do this ( as Mike suggested )
C:
struct BITACCESS{
   unsigned A : 1;
   unsigned B : 1;
   unsigned C : 1;
   unsigned D : 1;
   unsigned E : 1;
} flags;

flags.A = x;

Otherwise the compiler WILL use the hardware version.. On the pic's there is only 16 or so locations...


**NOTE** I may be talking about older ( smaller) pics..... I know 8051 does this.. I'm sure I read somewhere that pics do this aswell
BUT!! I cannot substantiate .. Take with pinch of salt!
 
Last edited:
All I know is... Pic assembly only allows bit access to a few ram locations... AVR may be the same... If your compiler is the GNU derivative ( I think it is )

Are you sure about that Ian?.

The 14 bit assembler bit based routines use 7 bit addressing, so will address 128 bytes per memory bank - with (often) the lower 32 as SFR, and the top 16 RAM locations common across all banks. So about a maximum of 80 bytes per bank, plus the 16 common ones.

Are you perhaps thinking of the common 16 bytes?, and if so is that perhaps a limitation of the C compiler?.
 
Are you sure about that Ian?.

The 14 bit assembler bit based routines use 7 bit addressing, so will address 128 bytes per memory bank - with (often) the lower 32 as SFR, and the top 16 RAM locations common across all banks. So about a maximum of 80 bytes per bank, plus the 16 common ones.

Are you perhaps thinking of the common 16 bytes?, and if so is that perhaps a limitation of the C compiler?.
Yeah! scrambling to find where I read it... I definitely know the 8051 does, I thought I read somewhere that because of banking the bit access was restricted to lower bank... But that probably ony happened way back.. I did used to use the old 12f508..
 
Yeah! scrambling to find where I read it... I definitely know the 8051 does, I thought I read somewhere that because of banking the bit access was restricted to lower bank... But that probably ony happened way back.. I did used to use the old 12f508..

The 12F508 isn't an old chip - it was the 'modern' replacement for the 12C508 :D

As far as I know there's no such restriction?, and nothing I could see in the datasheet on the 16F1827 on a quick look.
 
I used the 12F208 for a number of projects way back and can confirm there were no restrictions on using the 25 ( :eek:) bytes of memory - however, I was in assembly then.

Mike.
 
Yup.
508.png

Scary isn't it.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top