LIST p=PIC16F877A,r=hex ;microcontroller & base
INCLUDE "P16F877A.inc" ;register memory mapping file
;************************
; global variables
;************************
i equ 0x21 ;general purpose counter 1
j equ 0x22 ;general purpose counter 2
pot_ana_value equ 0x23 ;Analog value of the potentiometer
pwm_ana_value equ 0x24 ;Analog value of the PWM output after low filtering
#define timer_trigger 0x25, 0 ;This bit indicating the timer has been triggered
w_temp equ 0x26 ; temp variable for W register
status_temp equ 0x27 ; status variable for STATUS register
temp equ 0x28 ; general temp variable
;************************
; port definitions
;************************
#define led_data PORTD ;portD outputs 7-segment data
#define led_pot_high PORTB, 0 ;portB.0 selects high 4-bit value of pot
#define led_pot_low PORTB, 1 ;portB.1 selects low 4-bit value of pot
#define led_pwm_high PORTB, 2 ;portB.2 selects high 4-bit value of pwm
#define led_pwm_low PORTB, 3 ;portB.3 selects low 4-bit value of pwm
#define led_inc PORTB, 4 ;portB.4 drive the LED indicating PWM
;duty cycle increasing.
#define led_dec PORTB, 5 ;portB.5 drive the LED indicating PWM
;duty cycle decreasing.
;************************
; reload value of TMR0
; Timer 0 Interval = 5000 us
; 64 * ( 256 - TMR0 ) = 5000, TMR0 = 178 (0xB2)
;************************
tmr0_reload equ 0xB2
;************************
; 7-segment LED definitions
; a
; +----------+
; | |
; f| |b
; | g |
; +----------+
; | |
; e| |c
; | |
; +----------+ o dp