This program uses the PIC’s internal 16-bit timer (Timer1) to flash the LED. The timer is started by writing 0×31 to the T1CON register. This sets the pre-scaler to 8:1. The most significant bit of the timer (TMR1H bit 7) is rotated into the carry flag and then into bit 0 of TEMP (a user [...]
This program is similar to the LED dimmer except that when one LED is turned on, the other is turned off. As the potentiometer is turned from left to right, the brightness of LED D2 decreases and the brightness of LED D6 increases. Both LEDs are the same brightness when the pot is in its [...]
A 10-bit counter is compared with the value of the A/D from the pot. 4 LEDs are used to display the value, starting with the bottom LED. The brightness increases until it is at full brightness, then the next LED starts to light.
By changing ‘btfsc STATUS,C’ to ‘btfsc STATUS,Z’ (at around line 86), the bar [...]
In this program, the brightness of LED D0 is controlled by the position of the potentiometer, fully clockwise being maximum. The program uses the analogue to digital converter to read the potentiometer voltage and convert it to an 8-bit digital value. This value is used to control how early the LED is switched on in [...]
In this program LED D0 fades repeatedly from off to full brightness and back again. There are three nested loops starting at the ‘fade’ label. In the first loop (the inner loop) TRIG is compared with BRIGHT and the LED is switched on if they’re the same. The higher the value in BRIGHT, the earlier [...]
;12F675 Flashing LED using Timer1
list p=12F675
#include “p12f675.inc”
__CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF
TEMP equ 0×20
org 0×00
nop
goto init
org 0×04
return
init
banksel 0×80
clrf ANSEL ;make all I/O ports digital
movlw 0f
movwf TRISIO ;make GP4 and GP5 outputs
banksel 0×00
movlw 0×31
movwf T1CON ;start Timer1 running with 8:1 prescale
clrf GPIO ;turn off leds
flash
clrf TEMP
rlf TMR1H,w ;rotate TMR1H bit 7 into carry flag
rlf TEMP,f ;rotate carry flag to TEMP bit 0
swapf TEMP,f ;swap TEMP bit 0 to bit 4
movf TEMP,w
movwf GPIO ;copy TEMP to GPIO
goto flash
end
Continue reading about 12F675 Flashing LED using Timer1 overflow flag
Microchip’s advanced new family of 8 and 14-pin FLASH PIC microcontrollers now consists of 7 devices.
Since the 14-pin PICs have just one less I/O pin than the original 18 pin devices, due to the development of internal clock and reset modules, it’s clear that this package size will become increasingly popular.
Microchip are packing more and [...]
The PICkit 1 is Microchip’s new low-cost PIC programmer supporting the latest family of advanced 8 and 14-pin FLASH PIC microcontrollers.
It’s the perfect way to get into programming PIC microcontrollers! Simply install the programmer software on your PC, connect the USB cable and start programming. There are lots of tutorial files provided on the CD [...]