Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have an HC-SR04 ultrasonic sensor and a TM4C123G launch pad. I need to make a project using Keil-Uvision 5 using Arm assembly programming language.

I have an HC-SR04 ultrasonic sensor and a TM4C123G launch pad. I need to make a project using Keil-Uvision 5 using Arm assembly programming language. I need to measure the distance with the sensor. The trigg part of the sensor is connected to PD0, and the echo part is connected to PD1. The GPIO connection sections need to be completed for the code I wrote to run this system. GPIO codes must be added for the system to work.

The code I wrote:

image text in transcribed

. data distance: .word 0 @ variable to store distance in mm .text .global main main: mov r0, \#17 (@ set GPIO Port D pin 0 (PDO) as output mov r1, \#1 str r1,[r0] mov r,\#0 @ initialize loop counter loop: mov r1, \#1 @set PD0high str r1, [rO] mov 2 , \#0 @ delay for10us delay: add r2,r2,#1 cmp r2,\#200 blo delay mov r1, \#0 @ setPDOlow str r1,[rO] mov r0, \#16 @ set GPIO Port D pin 1 (PD1) as input mov r1, \#0 str r1,[r0] mov r0, \#18 @read PD1 ldr r1, [r0] cmp r1, \#0 @ wait for PD1 to go high beq loop mov r2, \#0 (a)reset timer timer: add r2,r2,\#1 @ increment timer cmp r2,\#60000@@ check if timer has reached 60,000 blo timer @ if not, keep waiting mov r0, \#16 @ set PD1 as output mov r1, \#1 str r1, [rO] mov r1, \#0 @ setPD1low str r1,[r0] Idr ro, =distance @ load address of distance into ro str 2 , [rO] @ store timervalue in distance mov r0, \#0 @ set return value to 0 (success) bx r @return

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Why would a national tendency toward saving cause deflation?

Answered: 1 week ago