Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello I\'m using HCS12 dragon-12 plus 2 microcontroller board from microdigital.

ID: 2294064 • Letter: H

Question

Hello I'm using HCS12 dragon-12 plus 2 microcontroller board from microdigital. It uses Assembly language programming with AsmIDE.

I need help converting this arduino code to AsmIDE assembly language. I'm supposed to convert it and then test and run the program on my dragon 12 board

#include Servo myservo: I/ create servo object to control a servo int potpin -0: /I analog pin used to connect the potentiometer int val: variable to read the value from the analog pin void setup) t myservo.attach (9)/ attaches the servo on pin 9 to the servo object void loop) t /I reads the value of the potentiometer (value between 0 and 1023) val-analogRead (potpin); val map (val, myservo.write(va1 1.25) delay (15) , 0, 1023, 0, 180) // scale it to use it with the ervo (value between 0 and 180) // sets the servo position according to the scaled value /I waits for the servo to get there

Explanation / Answer

strt: mov r0,#13

loop1: setb p1.0

acall servo_delay

clr p1.0

acall servo_delay_260

acall delay

mov a,r0

add a,#2

mov r0,a

cjne r0,#19,loop1

sjmp strt

servo_delay: mov tmod,#01h

mov th0,#0ffh

mov tl0,#0d2h

setb tr0

back: jnb tf0,back

clr tr0

clr tf0

djnz r0,$

ret

servo_delay_260: mov th0,#0d1h

mov tl0,#32h

setb tr0

back1: jnb tf0,back1

clr tr0

clr tf0

ret

delay: mov r1,#20

here: mov th0,#0dbh

mov tl0,#0ffh

setb tr0

back2: jnb tf0,back2

clr tf0

djnz r1,here

clr tr0

ret

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote