Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Am i on right track?

Status
Not open for further replies.

paris1

New Member
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:
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.
 
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.:)
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top