CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Using arrays to form a grid of bits

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Jim McBride
Guest







Using arrays to form a grid of bits
PostPosted: Fri Feb 28, 2003 12:20 am     Reply with quote

I would like to map out an area using a grid of x,y bits. I can set(clear/test) individual bits of a single dimension array with:
bit_set(grid[i],n), setting the nth bit of the ith variable types location in the array.
Is it possible to set bits in a two dimensional array?
i.e. grid[ix][iy]
I can't find any reference to setting bits in a multi-dimensional array.
Any help/ideas/new approaches will be greatly appreciated!!
JMc
___________________________
This message was ported from CCS's old forum
Original Post ID: 12204
Pete Smith
Guest







Re: Using arrays to form a grid of bits
PostPosted: Fri Feb 28, 2003 1:49 am     Reply with quote

:=I would like to map out an area using a grid of x,y bits. I can set(clear/test) individual bits of a single dimension array with:
:=bit_set(grid[i],n), setting the nth bit of the ith variable types location in the array.
:=Is it possible to set bits in a two dimensional array?
:=i.e. grid[ix][iy]
:=I can't find any reference to setting bits in a multi-dimensional array.

The CCS compiler doesn't allow arrays of bits. On occasion, it would be handy to do this automatically, but it doesn't hurt to do the conversion myself!

:=Any help/ideas/new approaches will be greatly appreciated!!

I do it pretty much the way you do it, but I use a function as a wrapper, so I have

write_array(value,x,y)

and

value=read_array(x,y)

where I pretty much do what you've done above.

Pete.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12206
Hans Wedemeyer
Guest







Re: Using arrays to form a grid of bits
PostPosted: Fri Feb 28, 2003 5:44 pm     Reply with quote

Is this what you mean... ?

I read you question and it appears to me you answered it yourself. ! :-) Athough you did not say how big the array should be, in the case of 32 X 32 bits

int32 Grid[32]; // becomes a 32 X 32 two dimensional array of BITS

Simply using your original code allows you to set/clear or get
any bit at x,y

bit_set(Grid[i],n); // where Grid[i] is the X and n is the Y

bit_clear(Grid[i],n);

bit_test(Grid[i],n);
___________________________
This message was ported from CCS's old forum
Original Post ID: 12244
Jim Mcbride
Guest







Re: Using arrays to form a grid of bits
PostPosted: Mon Mar 03, 2003 9:18 am     Reply with quote

<font face="Courier New" size=-1>:=:=I would like to map out an area using a grid of x,y bits. I can set(clear/test) individual bits of a single dimension array with:
:=:=bit_set(grid[i],n), setting the nth bit of the ith variable types location in the array.
:=:=Is it possible to set bits in a two dimensional array?
:=:=i.e. grid[ix][iy]
:=:=I can't find any reference to setting bits in a multi-dimensional array.
:=
:=The CCS compiler doesn't allow arrays of bits. On occasion, it would be handy to do this automatically, but it doesn't hurt to do the conversion myself!
:=
:=:=Any help/ideas/new approaches will be greatly appreciated!!
:=
:=I do it pretty much the way you do it, but I use a function as a wrapper, so I have
:=
:=write_array(value,x,y)
:=
:=and
:=
:=value=read_array(x,y)
:=
:=where I pretty much do what you've done above.
:=
:=Pete.

If I try to make an array large enouph for my application, I get out of ram errors pretty quick. Using 16 bit pointers halped a little, but not nearly enough. So I thought I would build my own array in memory directly using read/write_bank(). The problem is that no matter what I try the I can't simulate putting anything into memory where I want it. I tried turning off 16 bit pointers. I have tried all banks with no success. I can write to an address and get back a totally diferent number. What am I missing??

oops..
ok reading and writting to the same bank and getting data. Simulator File Register window still does not show data in memory location.</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12306
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group