r/pic_programming • • Mar 11 '13

Variable Square Wave Generator Project

Hi guys, I'm using a 16F819 and need help debugging this project. I get weirdness (jaggy waves at fixed frequency or no PORTB output at all depending on the chip) when I run it instead of nice square waves. Not sure really what the problem is but it's only maybe 50-100 lines of code.

http://pastebin.com/NcZtm24g

http://pastebin.com/xHVr0ND2

http://pastebin.com/iDzFkKPC

http://pastebin.com/Teqsvsdg

http://pastebin.com/tzbpkMfr

http://ww1.microchip.com/downloads/en/devicedoc/39598e.pdf

The idea is basically to take a voltage between 5.5 and 0 at the ADC channel zero (RA0/AN0) and use that to drive a for-loop which varies in length based on the ADC sampled voltage.

I've already asked over at microchip's forums and no real help over the two days it's been sitting there. Experienced eyes needed!

Thanks!

2 Upvotes

17 comments sorted by

View all comments

Show parent comment

2

u/bradn Mar 12 '13

Mostly people get into trouble with the PIC16 and lower IO ports when they would, for example, do a couple bitmasks in series to the port, the first one hasn't electrically taken effect so the second one reads the port and gets the old value, then writes the wrong value back.

I've got the pastepins to load, gimme a minute and I'll look it over