0

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
1
  • 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 those – Jack Jan 5 '20 at 10:48
1

You will find a good introduction on using port registers here. It also mentions some cons and pros of using port manipulation.

3
  • that documentation only applies to arduino boards using ATmega8 and ATmega168 chips, It does not apply to the due which uses a SAM3x ARM chip – Jack Jan 5 '20 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 Jan 5 '20 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 guess – Jack Jan 5 '20 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.