electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

bit structure for two dimmensional arrays


Post new topic  Reply to topic    EDAboard.com Forum Index -> PC Programming and Interfacing -> bit structure for two dimmensional arrays
Author Message
mformazhar1980



Joined: 23 Mar 2009
Posts: 14


Post28 Oct 2009 11:13   

bit structure for arrays


hi

i am intending to make a bit structure that i am going to use for storing boolean data into a two dimensional array.
the problem is i dont know exactly which data type is suitable so that i could save memory. i have used uint8_t as a data type. all i need to check whether i am on right track or not.

i want to store bits i.e 1's and 0's in a two dimensional array.
is that really save only the bits in said array or is it saving the whole bit in the index?
i.e suppose Value[0][j] stores {1,1,1,1,1}or
Value[1][j] stores {0,0,0,0,0}

the code snippet is as follows
Code:


unit8_t Value[4][10];

typedef struct Save_Bits
{
uint8_t  i  :1;
uint8_t  j  :1;

} Save_Bits;

struct Save_Bits  Value[i][j];



// then in the while loop get values




now the point is that how i can fetch all the data so that it can represent like

Value[0][j] stores all the 0's untill there is 1's appear and then it should immediately switches to Value[1][j] and store all the 1's there until the next change i.e occurrence of 0's again. and switches to Value[2][j] and store all the 0,s there and so on.
can any body help me to sort out the logic.
thanks


[/code]
Back to top
Google
AdSense
Google Adsense




Post28 Oct 2009 11:13   

Ads




Back to top
btbass



Joined: 20 Jul 2001
Posts: 1187
Helped: 113
Location: Oberon


Post30 Oct 2009 17:44   

Re: bit structure for arrays


One possible way to do it would be in a single array of bit counts.

psuedo code:

Code:


uint8_t data[ARRAY_SIZE];
uint8_t index = 0;
uint8_t count = 0;

while(index < ARRAY_SIZE)
  {
  while(READ_DATA() == 1)  /* Function READ_DATA() returns boolean */ 
    {
    data[index] = ++count;
    }

  index++;
  data[index] = count = 1;

  while(READ_DATA() == 0)
    {
    data[index] = ++count;
    }

  index++;
  data[index] = count = 1;
  }



You could reverse the logic to output the results.
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> PC Programming and Interfacing -> bit structure for two dimmensional arrays
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
best structure for a 12-bit DAC? (1)
adding two integer arrays in vhdl ... (1)
Implement 14-bit DAC in resistor-string structure? (4)
LPC1111 32-bit for 65 cent! 8-bit finally going obsolete? (3)
criteria for migrating from 8-Bit to 32-Bit Microcontroller (5)
Taylor Distribution for Planar Arrays (6)
Use of Floquet Ports for infinite arrays in HFSS (1)
Difference in Writing Code between 8-bit/16-bit/32-bit Micro (1)
How to declare large arrays in C compiler for PIC18 devices (5)
serial data to parallel two bit data (2)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS