We are getting there ... 136 and -223 degrees are actually two versions of the same value modulo 360 degrees. You can remove this problem by for example adding 360 to your result and compute the reminder of the division by 360. Or, an easier way to do that is, to add 360 to your result if it is negative.
Then there is a 180 degrees problem left. The most obvious cause could be, if you are running differential input in your MIO-board, that one of the input signal wire-pair is swapped. Is this the case? One thing you can try is to change your signal frequency to "move away from 90 degrees" and see if you still have an exact 180 deg problem, in which case you are sure that you have an un-wanted signal inversion somewhere in your signal paths.