Hi Jessey,
SLEEP uses the PIC WDT (watchdog timer) that's clocked by an internal RC oscillator. RC oscillators are affected by temperature, so timing can/will vary like the wind depending on temperature.Also I read somewhere that the sleep times will change with temperature as well.
Look in the Electrical Characteristics section of the data sheet (Table 22-7 in mine for the 18F452). You'll notice the WDT time-out period can be anywhere from 7mS min to 33mS max, so you should never expect precise time periods when using the WDT.
Not really. I just used it as a quick example. There are several ways to get similar results. I just prefer using WHILE..WEND.I've never seen code like your While X Wend code, I compiled a For..Next to compare and the for..next uses 2 bytes more to compile, is that why you used it?
I used PORTD because I used a LAB X1 board for the test, and it has an LED bargraph on PORTD.Another question, why did you use PORTD = PORTD ^ 1 in that code snip? I couldn't understand what it was doing in there and also if you could tell me, what does PORTD = 1 and TRISD = 0 do in pbp code?
PORTD = 1 is the sames as PORTD = %00000001. This just writes a 1 to the port to control the LED on PORTD.0.
TRISD = 0 simply makes all of the PORTD pins outputs, but all this stuff is covered in the PIC data sheet.
PORTD = PORTD ^ 1 is Exclusive ORing PORTD with 1 & toggling the LED on & off. The LED was used for a visual timing indicator.
Bookmarks