Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

assembly lang code help with timer interrupts

SENANSENAN Member Posts: 1
Hey

Im trying to write code to have a 2ms overflow so i can sample ecg waves at 500Hz i have hit a brick wall with this timer interrupt and any help would b greatly appreciated

Thanks



$MOD52

rd1 equ P0.0 ;Read signal P0.0
wr1 equ P0.1 ;Write signal P0.1
cs equ P0.2 ;Chip Select P0.2
intr equ P0.3 ;INTR signal P0.3

adc_port EQU P2 ;ADC data pins P2
adc_val EQU 30H ;ADC read value stored here

org 0H

start: ;Start of Program
acall conv ;Start ADC conversion
acall read ;Read converted value
mov P3,adc_val ;Move the value to Port 3
sjmp start ;Do it again

conv: ;Start of Conversion
clr cs ;Make CS low
clr wr1 ;Make WR1 Low
nop
setb wr1 ;Make WR High
setb cs ;Make CS high

wait:
jb intr,wait ;Wait for INTR signal
ret ;Conversion done

read: ;Read ADC value
clr cs ;Make CS Low
clr rd1 ;Make RD1 Low
mov a,adc_port ;Read the converted value
mov adc_val,a ;Store it in local variable
setb rd1 ;Make RD1 High
setb cs ;Make CS High
ret ;Reading done

END

Sign In or Register to comment.