M maia31 New Member Oct 3, 2011 #1 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?
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?
W wkrug Active Member Oct 4, 2011 #2 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: Oct 4, 2011
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.
W wkrug Active Member Oct 4, 2011 #3 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; } };
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; } };