Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/04/05 07:35
Read: times


 
#103286 - PCA Interrupt Help
Hi, Im have a bit of trouble with my PCA interrupt. I have setup the PCA module 0 using the intel pca cookbook to capture the first positive going edge and then the second positive going edge to measure the period - the signal ranges from 3ms to 50ms. Anyway, my problem is that PCA interrupt seems to be running twice per edge. I’ve set the incoming signal up using a toggle board so I can pulse the signal when needed. I’ve had a look at the signal on a scope and theres no double edge from the signal. I’m using the t89c51ac2 chip running at 11.0592MHz. Heres my code the I’m using. If I can a bit of input that would be great.
Cheers
Cameron

code: (includes a few extra bits for debugging)

;-----------------------------------------------------------------------------------------------
org 0003h ;external 0 isr
ljmp ex_isr
;-----------------------------------------------------------------------------------------------
org 001bh ;timer 1 isr
setb delay_done
clr tr1
mov th1,#timer1_h
mov tl1,#000h
reti
;-----------------------------------------------------------------------------------------------
org 0033h ;pca isr
sjmp pca_interrupt
;-----------------------------------------------------------------------------------------------
start: mov tmod,#10h ;timer 1 16 bit
mov th1,#timer1_h
mov tl1,#000h
mov menuflag,#3
setb ea
setb et1 ;timer 1 isr enable
setb ex0 ;external 0 isr enable
setb it0 ;ex0 edge detect
setb 0b8h ;ex0
mov testbit,#1
mov block,#84h
clr flagrpm
clr rpmwait
acall wakeup ;initialize the LCD
acall welcome ;welcome message to the LCD
test1: acall rpm_dis ;rpm display

acall menucheck ;check menu flag and run menu boost, water temp etc
sjmp test1
;-----------------------------------------------------------------------------------------------
pca_interrupt:
clr ccf0 ;clear module 0's event flag
inc block
mov a,block
acall writecmd
inc testbit
mov a,testbit
orl a,#30h
acall writedata
jb flagrpm,second_capture
first_capture:
mov captureL,ccap0l ;save 16bit capture value
mov captureH,ccap0h
mov ccapm0,#21h
setb flagrpm
mov a,#89h
acall writecmd
mov dptr,#debug3
acall sendmess
;mov r0,#15
;acall delay
reti
second_capture:
clr c
mov a,ccap0l ;16 bit subtract
subb a,captureL
mov rpm_captureL,a
mov a,ccap0h
subb a,captureH
mov rpm_captureH,a
mov a,#0c0h
acall writecmd
mov dptr,#debug1
acall sendmess
setb testflag1
reti
;-----------------------------------------------------------------------------------------------
ex_isr:
inc menuflag
push acc
mov a,#4
cjne a,#menuflag,next1
mov menuflag,#1
next1: pop acc
reti
;-----------------------------------------------------------------------------------------------
rpm_dis:
mov a,#80h
acall writecmd
mov dptr,#mess3
acall sendmess
mov cmod,#00h ;setup pca counter
mov ch,#00h
mov cl,#00h
mov ccapm0,#21h ;capture positve edge first with interrupt
setb ec ; enable pca isr
;etb cr ;turn pca timer on
jnb testflag1,$
mov dptr,#debug2

acall sendmess
mov r0,#255
acall delay
;acall hex2bcd
;mov a,#84h ;set character address
;acall writecmd
;mov a,r7
;orl a,#30h
;acall writedata
;mov a,r6
;orl a,#30h
;acall writedata
;mov a,r5
;orl a,#30h
;acall writedata
;mov a,r4
;orl a,#30h
;acall writedata
;mov a,r3
;orl a,#30h
;acall writedata
;mov r0,#100
;acall delay
;clr flagrpm
ret
;-----------------------------------------------------------------------------------------------
menucheck:
mov a,menuflag
cjne a,#1,not1
sjmp Duty_Cycle_mn
not1: cjne a,#2,not2
sjmp Boost_mn
not2: cjne a,#3,not3
sjmp water_temp
not3: mov menuflag,#1
ret
Duty_Cycle_mn: mov a,#0C0h
acall writecmd
mov dptr,#mess4
acall sendmess
ret
Boost_mn: mov a,#0C0h
acall writecmd
mov dptr,#mess6
acall sendmess
ret
water_temp: mov a,#0C0h
acall writecmd
mov dptr,#mess5
acall sendmess
ret
;-----------------------------------------------------------------------------------------------
welcome: mov r0,#55
acall delay
mov dptr,#mess1
mov a,#01h
acall writecmd
acall sendmess
mov a,#0c0h
acall writecmd
mov dptr,#mess2
acall sendmess
mov r0,#0ffh
acall delay
mov r0,#0ffh
acall delay
mov a,#01h
acall writecmd
ret

List of 4 messages in thread
TopicAuthorDate
PCA Interrupt Help            01/01/70 00:00      
   please reduce your code to the minimum            01/01/70 00:00      
      smaller code :)            01/01/70 00:00      
   What is the clock divider set to?            01/01/70 00:00      

Back to Subject List