Hi all,
Due to my limited programming experience, I always get stuck in pointer issues...
In detail, I know that
dim my_bit as sbit at LATB0_bit
....
my_bit = 1
is a valid and working construction.
Now I would need to create an array of pointers to a list of port bits, in order to access them with an index, like in (well, sort of...)
dim my_bit as sbit[3] at (LATB0_bit, LATE1_bit, LATG7_bit)
so to be able to do (sort of...)
my_bit[1] = 1
Now, I know that the above construction is awfully wrong, I tried fiddling with ^ and @ operators but I couldn't find a working syntax in order to accessing port bits "arrays" with an index.
Any suggestion? Thanks so much in advance!
Help on using sbit type
Re: Help on using sbit type
Hi,
Check in the help file of the compiler section "Accessing Individual Bits"
Reagrds,
Levi
Check in the help file of the compiler section "Accessing Individual Bits"
Reagrds,
Levi
Re: Help on using sbit type
Hi,
I don't understand exactly what do you mean by array of ports pointers .
Do you mean this?
stat = 0
for i = 0 to 9
stat = portb.i
next i
Regards,
Levi
I don't understand exactly what do you mean by array of ports pointers .
Do you mean this?
stat = 0
for i = 0 to 9
stat = portb.i
next i
Regards,
Levi
Re: Help on using sbit type
Hi Levi,
Sorry for not being that much clear, imagine that i want to set the bits of, say,
porta.0, portb.3 and portc.7
much like a sort of: (of course the following is awfully not correct)
const my_var as sbit[3] = (@porta.0, @portb.3, @portc.7)
so that that upon setting my_var[1] = 1, actually portb.3 is set.
Or in any other way where an index from 1 to n can address the n ports and bits, the constraint being that the ports and bits have not to be contiguous, like in your example, but arbitrarily defined in a list (or array, or structure...)
Sorry again, the confusion in my head is evident
Thanks,
Roberto
Re: Help on using sbit type
Hi Roberto,
As I know there is no way to create arrays with sbit and bit types .A workaround of what you need is a function I think
dim my_var as byte[3]
my_var[0]=0x01
my_var[1]=0x01
my_var[2]=0x00
porta.0= my_var[0].0
portb.3= my_var[1].0
portc.7= my_var[2].0
Regards,
Levi
As I know there is no way to create arrays with sbit and bit types .A workaround of what you need is a function I think
dim my_var as byte[3]
my_var[0]=0x01
my_var[1]=0x01
my_var[2]=0x00
porta.0= my_var[0].0
portb.3= my_var[1].0
portc.7= my_var[2].0
Regards,
Levi