Arduino Interrupts

So while working on the code for the control board part of the receiver project, I came across an interesting conflict. The keyboard and the rotary encoder did not want to play nice with each other than and the compiler was spitting out an error about a vector conflict. Keyboard worked fine by itself and the rotary encoder worked fine by itself but put the code for both into the once program and the compiler went bonkers.

So i set about learning everything i could about interrupts on the Mega 2560. And this was where the fun began and i ended up going down a rabbit hole from which i was lucky to escape. Well i did survive and i did actually learn about interrupt vectors, pin change interrupts and external interrupts and a little about library conflicts along the way.

So this is not really a tutorial on using interrupts or the differences between pin change or external, but rather a rant about the 2 hours I spent last night reading and trying to understand what I had done and why there was a conflict. In the end it was because i programmed the rotary encoder to use pin change interrupts and it was the library i used that was in conflict with the keyboard library. I did not know that was what i had done, i had assumed that using pins 18 and 19 on the mega, being the external interrupt pins just worked in one way only. But no no no, they can be either external or pin change interrupts depending on how you code for it. Yes, a very rookie mistake.

So after finally working out what I had done wrong, or in reality why the libraries were in conflict, i changed 2 lines of code and had the rotary encoder working as it should be with the keyboard and everyone is happy. So at the moment I have a working keyboard, rotary encoder and VFO and now that my work week is done, I will hit the code hard tomorrow and make some real inroads into getting features in there that I want in my radio. Its not going to be as pretty as the Nextion vfo codes that are floating about the internet, but its going to be all mine. And sometimes, its good to know you have rolled your own and it does what you want.

 

Facebooktwitterredditpinterestlinkedin