PDA

View Full Version : Need advise on copying waveform



financecatalyst
- 25th May 2013, 11:52
I want to copy a waveform I have with a starting pulse of appx 3.3mS high and then 1s and 0s follow it with their own high/low timings.
I have a PIC 16f676 and I wrote some code by measuring the high/low times on the waveform and then writing it as High Output_Pin : Pauseus 3300 : Low Output_Pin : Pauseus 130 ....and so on.

I then checked the waveform on an Osc.. and it does not match with what I wrote it as. For example Pauseus 130 while output pin is low is giving me 240uS low, I hope you get the idea of what I mean by timings don't match with the original waveform I am trying to copy.

Can anyone advise what is going wrong here? Thanks

HenrikOlsson
- 25th May 2013, 12:49
Hi,
Is the PIC actually running at the DEFINEd OSC frequency?
If you tell the compiler that it's supposed to be running at 20MHz but then only run it at 12MHz (or whatever) then all timings will be off by the ratio between actual and DEFINEd frequency.

/Henrik.

financecatalyst
- 25th May 2013, 13:14
Hi Henrik, it is running on internal 4MHz Oscillator and it is mentioned as 4MHz as define as well.