Timer operation int k1, k2, PIN = 8, sen void setup() { Serial.begin(9600); } void loop() { TCCR1A 0x00; TCNT1H 0x00; TCNT1L = 0x00; TCCR1B = 0x00; Set the default setting of Timer1 Reset high 8-bits of Timer1 Reset low 8-bits of Timer1 Disable Timer1 c1: sen digitalRead(PIN); if (sen = 1) goto c1; c2: sen = digitalRead(PIN); if (sen == 0) goto c2; c3: } TCCR1B 0x03; start Timer1 at Prescale Value of 64 sen = digitalRead(PIN); if (sen == 1) goto c3; TCCR1B 0x00; k1 TCNT1L; k2 TCNT1H; Serial.print (k1); Stop Timer1 Read Low 8-bits of Timer1 Read high 8-bits of Timer1 Serial.print(",,,"); Serial.print (k2); delay(1500); Serial.print(" TCNT1H 0x00; TCNT1L = 0x00; goto c; Reset high 8-bits of Timer1 Reset low 8-bits of Timer1 To clear Tiner1 over flow we must use TIFR1 = (1<< TOV1);

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter2: Introduction To Systems Architecture
Section: Chapter Questions
Problem 2VE: A(n) __________ is a storage location implemented in the CPU.
icon
Related questions
Question

1- Suppose we want to delay 2 sec at 16 MHz and a 64 prescale, write the program. In Arduino

 

Is it possible to create the code in the same format as the code in the image?

Timer operation
int k1, k2, PIN = 8, sen
void setup() {
Serial.begin(9600);
}
void loop() {
TCCR1A 0x00;
TCNT1H 0x00;
TCNT1L = 0x00;
TCCR1B = 0x00;
Set the default setting of Timer1
Reset high 8-bits of Timer1
Reset low 8-bits of Timer1
Disable Timer1
c1:
sen
digitalRead(PIN);
if (sen = 1) goto c1;
c2:
sen = digitalRead(PIN);
if (sen == 0) goto c2;
c3:
}
TCCR1B 0x03; start Timer1 at Prescale Value of 64
sen = digitalRead(PIN);
if (sen == 1) goto c3;
TCCR1B 0x00;
k1 TCNT1L;
k2
TCNT1H;
Serial.print (k1);
Stop Timer1
Read Low 8-bits of Timer1
Read high 8-bits of Timer1
Serial.print(",,,");
Serial.print (k2);
delay(1500);
Serial.print("
TCNT1H 0x00;
TCNT1L = 0x00;
goto c;
Reset high 8-bits of Timer1
Reset low 8-bits of Timer1
To clear Tiner1 over flow we must use
TIFR1 = (1<< TOV1);
Transcribed Image Text:Timer operation int k1, k2, PIN = 8, sen void setup() { Serial.begin(9600); } void loop() { TCCR1A 0x00; TCNT1H 0x00; TCNT1L = 0x00; TCCR1B = 0x00; Set the default setting of Timer1 Reset high 8-bits of Timer1 Reset low 8-bits of Timer1 Disable Timer1 c1: sen digitalRead(PIN); if (sen = 1) goto c1; c2: sen = digitalRead(PIN); if (sen == 0) goto c2; c3: } TCCR1B 0x03; start Timer1 at Prescale Value of 64 sen = digitalRead(PIN); if (sen == 1) goto c3; TCCR1B 0x00; k1 TCNT1L; k2 TCNT1H; Serial.print (k1); Stop Timer1 Read Low 8-bits of Timer1 Read high 8-bits of Timer1 Serial.print(",,,"); Serial.print (k2); delay(1500); Serial.print(" TCNT1H 0x00; TCNT1L = 0x00; goto c; Reset high 8-bits of Timer1 Reset low 8-bits of Timer1 To clear Tiner1 over flow we must use TIFR1 = (1<< TOV1);
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning