<<Previous

Next>>

5.34. SLEEP

SLEEP Period

Places PICmicro in low power mode for Period seconds. Period is 16-bits, so delays can be up to 65,535 seconds (just over 18 hours). SLEEP uses the Watchdog Timer so the resolution is 2.3 seconds. To compensate for the inherent inaccuracy of the WDT (which is driven by an R/C oscillator), SLEEP calibrates the WDT by measuring it relative to the system clock. Thus, SLEEP is as accurate as the system clock. In order to account for temperature drift of the R/C oscillator, the WDT is calibrated approximately every ten minutes.

Sleep 60 'Sleep for 1 minute

 

5.35. SOUND

SOUND Pin,( Note, Duration{, Note, Duration} )

Generates tone and/or white noise on the specified Pin. Note 0 is silence. Notes 1-127 are tones. Notes 128-255 are white noise. Tones and white noises are in ascending order (i.e. 1 and 128 are the lowest frequencies, 127 and 255 are the highest). Duration is 0-255 and determines how long the Note is played. Note and Duration needn't be constants. Pins are numbered 0 to 7.

SOUND outputs TTL-level square waves. Thanks to the excellent I/O characteristics of the PICmicro MCU, a speaker can be driven through a capacitor. Piezo speakers can be driven directly.

Sound 7,(100,10,50,10) 'Send 2 sounds consecutively to Pin7

 

5.36. TOGGLE

TOGGLE Pin

Inverts the state of the specified pin. The pin is automatically made an output pin. Pins are numbered 0 to 7.

Low 0 'Start Pin0 as low
Toggle 0 'Change state of Pin0 to high

 

5.37. WRITE

WRITE Address, Value

Writes Value to the EEPROM at the specified Address. This instruction may only be used with a PICmicro that has an on-chip EEPROM data area such as the PIC16C84, 16F62x, 8x and 87x.

Write 5,B0 'Send value of B0 to EEPROM location 5

<<Previous

Next>>