write8(1, 16#40); If i understand it correct should this write BIT 4 in register 01?
write
HoldCmd :BYTE :=16#F4;
write(ADR(HoldCmd),1);
This will write a byte into register 16 # F4.
But what bits?
All to 1 or all to 0 or something completely different?
writeBits
But unfortunately I have no idea how to use this command.
I would be very grateful for a short description
Input usiRegister USINT register
usiFirstBit USINT highest value bit to write (0..7)
usiLength USINT number of bits to write (1..usiFirstBit+1)
usiValue USINT value of the bits to set (0..2^usiLength-1)
Thanks in advance.
BR
MR. Pioneer
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everybody,
I need a brief explanation.
I would like to create an i2C library in which I have to write individual bits in different registers.
Specifically, this means
Register (0x01)
Bit 4
Possibly can someone write me a short code how this works.
I have the following methods available within the library.
write
write8
writebits
Thanks in advance.
write8
write8(1, 16#40); If i understand it correct should this write BIT 4 in register 01?
write
HoldCmd :BYTE :=16#F4;
write(ADR(HoldCmd),1);
This will write a byte into register 16 # F4.
But what bits?
All to 1 or all to 0 or something completely different?
writeBits
But unfortunately I have no idea how to use this command.
I would be very grateful for a short description
Input usiRegister USINT register
usiFirstBit USINT highest value bit to write (0..7)
usiLength USINT number of bits to write (1..usiFirstBit+1)
usiValue USINT value of the bits to set (0..2^usiLength-1)
Thanks in advance.
BR
MR. Pioneer
Hi!
This actually can be very easy, when I got your question right π. I would intuitively use Write8, as you did.
The interface is roughly:
Write8(usiRegister, usiValue)
So, to write your bit 4 to register 1, you need to call s.th. like this:
Alternatively, you can write it in binary form, instead of hex: