I would like to read multiple pins at once in Arduino Due via registers just like PINB, PINC, PIND of the arduino uno. I know that the pins will be scattered to multiple registers, but i deduce it would still be faster this way since there for sure there will be multiple pins on a single register rather than call digitalRead 40 times.
Arduino shared the documentation for what digital/analog pins corressponds to the what ports to the actual sam chip, i just need that snippet of code that reads via registers.
So if any can give me the equivalents to these, It would be greatly appreciated:
- DDRx - The Port C Data Direction Register - read/write
- PORTx - The Port C Data Register - read/write
- PINx - The Port C Input Pins Register - read only
-
i just wrote x because there are three of those e.g. DDRB,DDRC,DDRD. basing from that there should be port A but i guess they dont use thoseJack– Jack01/05/2020 10:48:22Commented Jan 5, 2020 at 10:48
1 Answer 1
You will find a good introduction on using port registers here. It also mentions some cons and pros of using port manipulation.
-
that documentation only applies to arduino boards using ATmega8 and ATmega168 chips, It does not apply to the due which uses a SAM3x ARM chipJack– Jack01/05/2020 12:46:50Commented Jan 5, 2020 at 12:46
-
You are right. I didn't read your headline carefully enough. But apparently this question has been asked (and answered before): arduino.stackexchange.com/questions/9117/…Andreas– Andreas01/05/2020 14:16:06Commented Jan 5, 2020 at 14:16
-
Wow I did not see that, it will be useful to me in future projects. Unfortunatly they are only talking about writing to the pins and not reading the pins. I could not find a mention on reading pins. Although I may have found a hint from a answer of this question, I will have to start from there i guessJack– Jack01/05/2020 14:38:59Commented Jan 5, 2020 at 14:38