When Im changing from digitalWrite to gpio_write_bit everything goes good.
but gpio_read_bit doesn't work. I just need faster gpio readings.
pinMode(PF3, INPUT);
pinMode(PF5, INPUT);
//temporary debug display:
display.clearDisplay();
display.setCursor(8, 0);
display.print(gpio_read_bit(GPIOF, 3));
display.setCursor(8, 56);
display.print(gpio_read_bit(GPIOF, 5));
display.display();
returns "8" for pin F3 and "32" for pin F5?
what Im doing wrong?
How much gpio_read_bit should be faster than digitalRead?
Thank you.
a little question about gpio_read_bit
Re: a little question about gpio_read_bit
F3 is bit 3 returns 2^3 = 8, and F5 gives 2^5 = 32
Re: a little question about gpio_read_bit
Oh. It makes sense..!
But how do i read a single pin input state high/low?
Like digitalRead(PF3) but faster.
Should it be like this:
if gpio_read_bit(GPIOF, 3) == 0 means pin grounded, if !=0 then floating or pulled to vcc?
I thought it gona be "0" and "1" respectively, but ok..
But how do i read a single pin input state high/low?
Like digitalRead(PF3) but faster.
Should it be like this:
if gpio_read_bit(GPIOF, 3) == 0 means pin grounded, if !=0 then floating or pulled to vcc?
I thought it gona be "0" and "1" respectively, but ok..
Re: a little question about gpio_read_bit
There is no "gpio_read_bit" for fast read in Roger's core.
If you want fast read you need to get data from registers:
x - port (A,B, C, D, etc).
If you want fast read you need to get data from registers:
Code: Select all
GPIOx->regs->IDR
-
- Posts: 505
- Joined: Fri Dec 27, 2019 4:53 pm
- Location: Munich, Germany
- Contact:
Re: a little question about gpio_read_bit
The function gpio_read_bit() does what its name say. The output is zero if pin is tied to GND, non-zero otherwise.
If you want to make a "1* out of it then you have to shift right the read value with the number corresponding to the bit position.
If you want to make a "1* out of it then you have to shift right the read value with the number corresponding to the bit position.
Last edited by stevestrong on Wed Dec 09, 2020 8:14 am, edited 2 times in total.
Re: a little question about gpio_read_bit
bit is a bit!
Thank you all! I got it!! What a good feeling!
Thank you all! I got it!! What a good feeling!
