GIDForums  

Go Back   GIDForums > Computer Programming Forums > Assembly Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-Apr-2008, 03:44
SENAN SENAN is offline
New Member
 
Join Date: Apr 2008
Posts: 2
SENAN is on a distinguished road

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  
Old 03-Apr-2008, 11:39
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,693
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Sampling at 500Hz (2ms)


Quote:
Originally Posted by SENAN
Code:
wait: jb intr,wait ;Wait for INTR signal ret ;Conversion done

I assume that intr is some bit definition associated with your timer.

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  
Old 03-Apr-2008, 13:16
SENAN SENAN is offline
New Member
 
Join Date: Apr 2008
Posts: 2
SENAN is on a distinguished road

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  
Old 03-Apr-2008, 13:43
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,693
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Sampling at 500Hz (2ms)


Quote:
Originally Posted by SENAN
...set up a timer to overload every 2ms...

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 GIDBlogMeeting the local Iraqis by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:18.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.