There is no documentation in the source file I looked at. This makes it impossible for me to follow it.
Additional to that it (obviously) refers to pins on the uC. I have no idea what they are supposed to be used for or connected to.
What I suggest you do is go through the code and document everything. What the variables mean, that the pins are used for, what each section is trying to achieve, what each line does.
If, after that, you can't find the problem yourself, then you can post the code here, and intersperse the code with a longer and deeper explanation of what it's doing (or what the user does to trigger this code's execution, and what it's doing wrong (etc).
The mere act of documenting code is often enough to help you find bugs. If not, the act of explaining the problem to someone else will almost always yield some insight that is hard to get if you just run this stuff through our own head.
I often use colleagues at work for this, I have used mt wife too. Once, when desperate, I used the cat. (Yes, I was successful using the cat.)