Read and Write to registers
hi,
i'm new in programming arduinouno , have example code how read , write directly various in , output data registers without using digitalwrite(), digitalread() , analogread().
all best /gg
i'm new in programming arduinouno , have example code how read , write directly various in , output data registers without using digitalwrite(), digitalread() , analogread().
all best /gg
read port:
byte value = pinx; // x = a,b,c,d etc.
write port:
porty = 0x00 oxff; // y = a,b,c,d etc.
act on single bit:
if ((pind & 0b00000100) == 0){ // bit 2 of port d for example
// bit 0, something
}
else {
// bit 1, else
}
writing single bit:
portd = portd & 0b11111011; // make bit 2 of port d 0 (clear bit), leaving rest alone
portd = portd | 0b00000100; // make bit 2 of port d 1 (set bit), leaving rest alone
have not tried same analogread, suggest you use time allowed 110us conversion.
byte value = pinx; // x = a,b,c,d etc.
write port:
porty = 0x00 oxff; // y = a,b,c,d etc.
act on single bit:
if ((pind & 0b00000100) == 0){ // bit 2 of port d for example
// bit 0, something
}
else {
// bit 1, else
}
writing single bit:
portd = portd & 0b11111011; // make bit 2 of port d 0 (clear bit), leaving rest alone
portd = portd | 0b00000100; // make bit 2 of port d 1 (set bit), leaving rest alone
have not tried same analogread, suggest you use time allowed 110us conversion.
Arduino Forum > Using Arduino > Programming Questions > Read and Write to registers
arduino
Comments
Post a Comment