Go Down

Topic: Arduino DUE, hardware implement of XOR (Read 713 times) previous topic - next topic

mcf3lmnfs

Is it possible by setting the right registers on Arduino DUE to implement hardware XOR gate. I would need such an option as an alternative to do it in software. I have two input signals.

My current settings are to use an Interrupt for each of the pins. So two interrupts. But if i were able to join the two signals, i would be able to use only one. My goal is to use only one.

I am also limited to not changing any of the elements, so we can not add external XOR gate. So i am wondering if there might be a chance of somehow rewire the inside transistors in arduino in a way for example, it would always take input from pin 2 and 3 and xor it and output the result on lets say pin 4. I wasnt reading any datasheet about it as i should, but i imagine it might be possible. Does anyone have a quick answer about yes/no and in case of a yes how or pointing me in right directions.

Thank you for your help.

ard_newbie

Is it possible by setting the right registers on Arduino DUE to implement hardware XOR gate
AFAICT no hardware solution, only software.

My current settings are to use an Interrupt for each of the pins. So two interrupts
What is issue with that ?


If you read PIOx->PIO_PDSR Inside each interrupt, and decide to set (PIOx->PIO_SODR)/reset (PIOx->PIO_CODR) a pin c whether an XOR operation between pin a and pin b is 1 or 0, this should be pretty fast.

What is pin a and pin b maximum toggling frequency ?

mcf3lmnfs

What is issue with that ?

The goal was to get rid of as many interrupts as possible, because it can lead to undetermenistic exectution of the program.

We have choosen the solution with two interrupts for now.  Thank you for your help

weird_dave

If you're worried about non determinism, do as little as possible in the interrupt, I have an interrupt which simply sets a flag, the event is then dealt with in the main loop. Of course, this depends on what you're trying to do, but we have nothing to go on....
XOR probably isn't what you want anyway, if both interrupts were to come in at once, you'd get neither.

HermannSW

It is not possible with Due hardware.

I once needed an XOR gate, and before I received it I built it up in software:
https://forum.arduino.cc/index.php?topic=291435.msg3148728#msg3148728

The delay of software XOR was 375ns, while the delay of hardware XOR IC is only 22.5ns. If you cannot accept 375ns delay, then XOR IC is your only option.
https://forum.arduino.cc/index.php?topic=462107.msg3236016#msg3236016
http://stamm-wilbrandt.de/en/Raspberry_camera.html

Go Up