![]() |
|
#1
|
|||
|
|||
Sampling at 500Hz (2ms)Hey
what im tryin to do is set up a timer to overflow every2 ms so this code will sample an ecg wave at 500Hz. Cant get my head around how to do this and any help would be 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 |
|
#2
|
|||
|
|||
Re: Sampling at 500Hz (2ms)Quote:
If I understand it, program execution stays here until the bit defined by intr is set, and then returns to the calling function. So: 1. Is the timer free-running with a 2 ms period? Does reading the signal automatically reset it or what? 2. How long does the signal tested by the jb instruction stay high? 3. How long does the signal tested by the jb instruction stay low? Have you tried this code in your target system? What happens when you do? Regards, Dave |
|
#3
|
|||
|
|||
Re: Sampling at 500Hz (2ms)Hey
The intr is a signal sent from an external ADC to let you know that the conversion has taken place. The ecg sensor is going to be running freely and basically what i want to do is to have this code sampling these signals at 500Hz so i what to set up a timer to overload every 2ms to achieve this. the code i have at the moment runs fine and i get samples showing in P3. its just trying to get this 500Hz sampling that i cant get.. Regards Senan |
|
#4
|
|||
|
|||
Re: Sampling at 500Hz (2ms)Quote:
Look in the hardware and/or software manual for your processor and development tool set: Look for examples and/or application notes that tell how to set up a timer for that particular processor and how to use whatever status bit you have defined to work with that timer. You will almost surely have to know something about clock speed and, perhaps, other hardware features of your particular board. Regards, Dave |
Recent GIDBlog
Meeting the local Iraqis by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The