Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 29th May 2008, 09:40 AM   (permalink)
Default Am i on right track?

Hi I studied assembly language in college but its been a few years since ive seen it. Could anyone tell me if im on the right track, my syntax is wrong but i just want to know if i remember the principles correctly. The following code is intended to measure the duty cycle of three inputs from an accelerometer. I know its not going to be right but i just want to know if im starting from the very beginning. Thanks

START:
INPUT_1: CJNE P1.1, "1", INPUT_1;----------------//WAIT FOR LINE TO GO HIGH
SETB T1;-------------------------------//START TIMER
LOW: CJNE P1.1, 0, LOW--------------------- //WAIT FOR LINE TO GO LOW
MOV T1 @ R0----------------------- //MOVE VALUE ON TIMER TO ADDRESS
INC RO -----------------------------//INCREMENT R0 TO CHANGE ADDRESS

2: IF P1.2 = 1;---------------------------//SAME PROCESS FOR 2ND INPUT
EN T1
IF P1.2 = 1;
MOV T1 @ R0
INC RO

3: IF P1.3 = 1;-----------------------------//SAME PROCESS FOR 3RD INPUT
EN T1;
IF P1.3 = 1
MOV T1 @ R0
MOV RO, ?-------------------// RESET R0 TO POINT TO ORIGINAL ADDRESS

Last edited by paris1; 29th May 2008 at 09:43 AM.
paris1 is offline   Reply With Quote
Old 29th May 2008, 10:07 AM   (permalink)
Default

Quote:
Originally Posted by paris1 View Post
Hi I studied assembly language in college but its been a few years since ive seen it. Could anyone tell me if im on the right track, my syntax is wrong but i just want to know if i remember the principles correctly. The following code is intended to measure the duty cycle of three inputs from an accelerometer. I know its not going to be right but i just want to know if im starting from the very beginning. Thanks

START:
INPUT_1: CJNE P1.1, "1", INPUT_1;----------------//WAIT FOR LINE TO GO HIGH
SETB T1;-------------------------------//START TIMER
LOW: CJNE P1.1, 0, LOW--------------------- //WAIT FOR LINE TO GO LOW
MOV T1 @ R0----------------------- //MOVE VALUE ON TIMER TO ADDRESS
INC RO -----------------------------//INCREMENT R0 TO CHANGE ADDRESS

2: IF P1.2 = 1;---------------------------//SAME PROCESS FOR 2ND INPUT
EN T1
IF P1.2 = 1;
MOV T1 @ R0
INC RO

3: IF P1.3 = 1;-----------------------------//SAME PROCESS FOR 3RD INPUT
EN T1;
IF P1.3 = 1
MOV T1 @ R0
MOV RO, ?-------------------// RESET R0 TO POINT TO ORIGINAL ADDRESS
hi,
I would test to see if the line is already high when I enter the routine.
example: the INPUT_1: CJNE P1.1, "1", INPUT_1;----------------//
may already be high, if its running asynchronously.
So IF HIGH wait for LOW, then Start Timer/counter on next HIGH going edge.
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is online now   Reply With Quote
Old 29th May 2008, 10:11 AM   (permalink)
Default

Thanks, thats good advice. hopefully that sort of thing will come back to me
paris1 is offline   Reply With Quote
Old 29th May 2008, 11:04 AM   (permalink)
Default

Quote:
Originally Posted by paris1 View Post
Thanks, thats good advice. hopefully that sort of thing will come back to me
hi,
I have just written a similar program 'snippet' for two 'accelerometer' inputs,
look a 'Atomsoft's recent posts regarding acc, it may help.
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/

Last edited by ericgibbs; 29th May 2008 at 11:04 AM.
ericgibbs is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
PCB track thickness johnl69 General Electronics Chat 4 23rd July 2007 10:52 AM
Am I on the right track? Andy1845c Micro Controllers 3 1st February 2007 01:19 PM
Track width 20A leonel General Electronics Chat 9 28th October 2005 04:39 PM
Antenna PCB track Scarr General Electronics Chat 11 29th March 2005 06:50 AM
PCB track width ... jmantilla General Electronics Chat 1 4th October 2004 12:59 AM



All times are GMT. The time now is 11:48 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.