Hi,
Like EasyPeasy said, it's impossible to find the cause if you don't show us all your project.
Schematic, PCB layout, code, scope pictures, your expectation ..
It could be any of the above:
* wrongly dimensionated filters, power supply bypassing (schematic)
* wrong wiring, no really solid GND plane (PCB)
* jittery square wave caused by code oroblems
* wrong measurement method
....
You say you made everything right but ... there's obviously something wrong.
So show us what you did, so we are able to validate it.
Klaus