Using Arduino/RPi Interrupt Pins in base overlay

Hello there,

I’ve been tinkering with a pynq-z2 for a week now and I am now trying to use Arduino/Raspberry Pi pins in the ‘base.bit’ overlay as interrupts, currently for calculating an optical encoder’s pulse. I am unable to figure that out. If you guys could give an example, That would be great help. Thank you.

Can you provide more info?


I want to Implement this Arduino Code for PYNQ-Z2 base layout

int encoderPin1 = 2;
int encoderPin2 = 3;
volatile int lastEncoded = 0;
volatile long encoderValue = 0;
long lastencoderValue = 0;
int lastMSB = 0;
int lastLSB = 0;
void setup() {
Serial.begin (9600);
pinMode(encoderPin1, INPUT);
pinMode(encoderPin2, INPUT);
digitalWrite(encoderPin1, HIGH); //turn pullup resistor on
digitalWrite(encoderPin2, HIGH); //turn pullup resistor on
//call updateEncoder() when any high/low changed seen
//on interrupt 0 (pin 2), or interrupt 1 (pin 3)
attachInterrupt(0, updateEncoder, CHANGE);
attachInterrupt(1, updateEncoder, CHANGE);
void loop(){
//Do stuff here
delay(1000); //just here to slow down the output, and show it will work
even during a delay
void updateEncoder(){
int MSB = digitalRead(encoderPin1); //MSB = most significant bit
int LSB = digitalRead(encoderPin2); //LSB = least significant bit
int encoded = (MSB << 1) |LSB; //converting the 2 pin value to single
int sum = (lastEncoded << 2) | encoded; //adding it to the previous
encoded value
if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011)
encoderValue ++;
if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000)
encoderValue --;
lastEncoded = encoded; //store this value for next time

I’m focusing on the interrupt part (Rising, Falling, Change). Kindly give a python implementation in PYNQ-Z2 for this code.