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.

100bit array in codevision

Status
Not open for further replies.

maia31

New Member
i want build fifo
so i define an array
a[100]
but i dont the type of my aaray?
because the max bit support in codevision is for type long int and it is 64 bit not 100 bit
so what should i do?
 
volatile bit a[100];
doesn't work.
You can create a Byte Array with.
volatile char a[13];
So you get an Array with can contain 104Bits

To Adress the Byte you have to divide it by 8.
byte = bitcount/8;
To get the Bit in that Array you should use the Rest Function
bit = bitcount%8;

byte=bitcount/8;
xbit=bitcount%8;
if(a[byte]&&(1<<xbit)>0)
{
result=1; //The Adressed Bit was 1
}
else
{
result=0; //The Addresed Bit was 0
}

I've not tested yet, but i think it will be work.
 
Last edited:
Update:
I've tested with AVR Studio Simulator.
That routine works!
Code:
// Declare your local variables here
volatile unsigned char a[13];    //104 Bits
volatile unsigned char byte,xbit,result; //Helper Variables
volatile unsigned char bitcount=67;  //Adressed Bit
....

....
byte=bitcount/8;
 xbit=bitcount%8;
 if((a[byte]&(1<<xbit))==0)
    {
    result=0;
    }
 else
    {
    result=1;
    }
 };
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top