0% found this document useful (0 votes)
256 views2 pages

Ccp1 Capture Mode - Polling

This document contains assembly code for using the CCP1 module in capture mode with interrupt flag polling on the PIC16F877A microcontroller. It initializes the CCP1 module and timer 1 to operate in capture mode. It then enters a polling loop to continuously check if the CCP1 interrupt flag is set. If set, it clears the timer 1 registers and copies the captured value from the CCP1 registers to output ports before rechecking the interrupt flag.

Uploaded by

taswarmahbub
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
256 views2 pages

Ccp1 Capture Mode - Polling

This document contains assembly code for using the CCP1 module in capture mode with interrupt flag polling on the PIC16F877A microcontroller. It initializes the CCP1 module and timer 1 to operate in capture mode. It then enters a polling loop to continuously check if the CCP1 interrupt flag is set. If set, it clears the timer 1 registers and copies the captured value from the CCP1 registers to output ports before rechecking the interrupt flag.

Uploaded by

taswarmahbub
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

F:\latest 877a\CCP Module\Capture 2(polling) Module\ccp1_cap_polling.

asm
; USE OF TIMER1 IN CCP(CAPTURE)MODE-USE OF CCP1 WITH CCP1
; INTR FLAG POLLING
; --------------------------------------------------------------; PROGRAMMER-- SYED TASWAR MAHBUB
; DATED-- 30-08-15
; CCP1 CAPTURE MODE DEMO WITH CCP1 INTERRUPT FLAG POLLING
;--------------------------------------------------------------TITLE : "USE OF CCP1 MODULE IN CAPTURE MODE USING POLLING"
LIST

P=16F877A

#INCLUDE "P16F877A.INC"
__CONFIG

H'3F71'

;SFR SHOWN BELOW NEEDNOT TO BE SHOWN WITH MEMORY ADDRESS AS IT IS


;INCLUDED IN ABOVE MENTIONED .INC FILE BUT SHOWN HERE SO THAT NEW
;PORGRAMMER CAN SEE IN WHICH MEMORY BANKS THESE SFRS ARE LOCATED.

STATUS
PORTB
INTCON
PIR1
TMR1L
TMR1H
T1CON
CCPR1L
CCPR1H
CCP1CON
TRISB
TRISC
PIE1
ADCON1

EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU

0X03
0X06
0X0B
0X0C
0X0E
0X0F
0X10
0X15
0X16
0X17
0X86
0X87
0X8C
0X9F

;
;
;
;

IN
IN
IN
IN

BANK
BANK
BANK
BANK

1
1
1
1

SO
SO
SO
SO

BANK
BANK
BANK
BANK

CHANGE
CHANGE
CHANGE
CHANGE

IS
IS
IS
IS

REQUIRED
REQUIRED
REQUIRED
REQUIRED

;-----------------------------------------------------------------ORG
GOTO

0X00
INIT

;------------------------------------------------------------------INIT
BANKSEL
CLRF
CLRF
MOVLW
MOVWF
BSF
BANKSEL
CLRF
CLRF
BCF
BCF
BANKSEL
BCF
BCF
BANKSEL
BCF
CLRF
MOVLW
MOVWF
CLRF
CLRF
CLRF

TRISB
TRISB
TRISD
B'00000110'
ADCON1
TRISC,2
PORTB
PORTB
PORTD
INTCON,7
INTCON,6
PIE1
PIE1,0
PIE1,2
PIR1
PIR1,2
CCP1CON
B'00000000'
T1CON
TMR1H
TMR1L
CCPR1H

; TURN OFF A/D, PORTA=DIGITAL I/O


;CCP1 PIN INPUT

; DISABLE GLOBAL INTR


; DISABLE PERIPHERAL INTR
; DISABLE TMR1 INTR
; DISABLE CCP1 INTR
;
;
;
;

CLEAR CCP1 INTR FLAG


CCP1 MODULE OFF,CLEAR CCP1 PRESCALER
TMR1 PRESCALER AND TMR1 SETUP
TMR1 OFF

F:\latest 877a\CCP Module\Capture 2(polling) Module\ccp1_cap_polling.asm


CLRF
MOVLW
MOVWF

CCPR1L
B'00000101'
CCP1CON ; CCP1 IN CAPTURE MODE, CCP1 ON

BANKSEL T1CON
BSF
T1CON,0
AGAIN

BTFSS
GOTO
CLRF
CLRF
BCF
MOVF
MOVWF
MOVF
MOVWF
GOTO

PIR1,2
$-1
TMR1L
TMR1H
PIR1,2
CCPR1H,W
PORTD
CCPR1L,W
PORTB
AGAIN

; TIMER1 ON
; CHECK WETHER CCP1 INTR FLAG IS SET OR NOT
; CLEARING TIMER1 LOW REGISTER
; CLEARING TIMER1 HIGH REGISTER
; CLEAR CCP1 INTR FLAG
; SENDING STORED HIGH BITS TO PORTD
; SENDING STORED HIGH BITS TO PORTB

END
;--------------------------------------------------------------

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy