1
I am therefore an Arduino code for the PIC pro compiler Mikroc. I arrived at a part that contains the following:
byte data[3];
// pulse the clock pin 24 times to read the data
for (byte j = 3; j--;) {
for (char i = 8; i--;) {
digitalWrite(PD_SCK, HIGH);
bitWrite(data[j], i, digitalRead(DOUT));
digitalWrite(PD_SCK, LOW);
}
}
I managed to arrange it for:
byte data[3];
int j;
int i;
// pulse the clock pin 24 times to read the data
for (j = 3; j--;) {
for (i = 8; i--;) {
RD1_bit = 1;
bitWrite(data[j], i, RD0_bit);
RD1_bit = 0;
}
}
Thus, only the function is missing bitWrite(data[j], i, RD0_bit);
work, but I did not reach conclusive results.
I currently have the following code, which is not running:
void bitWrite(uint8_t &x, unsigned int n, int b1) {
if (n <= 7 && n >= 0) {
if (b1) {
x |= (1u << n);
} else {
x &= ~(1u << n);
}
}
}
Note: Unique include
that I’m using is #include <stdint.h>
I don’t know this compiler and I’ve never used Adian. From what I’ve seen
byte
is not a standard type or compiler http://www.mikroe.com/download/documents/compilers/mikroc/pro/pic/help/arithmetic_types.htm or dostdint.h
. Now the most important in thebitWrite
it seems that these to pass x as reference, but this does not exist in C and what variable is the1u
?– krystalgamer
@Giovani, does the code show an error? This
1u
seems to me a constant of some library of the Mikroc, thereforex& = ~(1u << n)
is a bit mask and1u
need to have some value for it to work.– Avelino
@krystalgamer thanks for the help, I managed to resolve.
– Giovani
@Avelino thanks for the help, I managed to resolve.
– Giovani
@Giovaniracipaganini I was curious to know what this code does. Generates a square wave on pin 3? (Or pin 4 starts at 0)!?
– Avelino
@Avelino Gero is a 24-bit square wave, with each bit representing a bit, as it is a 24-bit converter. To learn more see the HX711.cpp file available on the internet.
– Giovani