I think, the problem is that all variables, including drivePos, are declared in the global scope. The first time you call getBallPID() function, drivePos value is zero and it lets you enter while loop:
However, the second time you call getBallPID(), drivePos already has a non-zero value that is larger than target=2.3, which prevents you from entering the loop.
The best way to fix this is to declare such variables local to the function and initialize them to zero before they are used.
Also, you may want to check out some of the PID drive code examples in topics linked from this post.