Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write s program using an Interrupt Service Routine that does the following : Q3. [8 marks] Write a program using an Interrupt Service Routine that

Write s program using an Interrupt Service Routine that does the following :

image text in transcribed

Q3. [8 marks] Write a program using an Interrupt Service Routine that does the following : Waits for a Single High Pulse of 200 ms,on Pin OC1. When the High Pulse goes from High to low, it turns ON the LED at Port A,RA0 and the LED then stays on. You will use the Output Compare OC1, Dual Compare mode with a Single High Pulse (OCM=004). You will use Timer 2 for the OC with a pre-scale value of 256 . You need to setup OC1RS and OC1R such that OC1RS - OC1R =200ms We need to convert 200m into Timer Clock Cycles. We have Timer 2 with a 80Mbz PBClk and a Precale, of 256. We will use the PR formula for the Timer delay from before. 200ms=(PR+1)/(pBLCK/256)20010(3)=(PR+1)/(80106/256)) instead of PR+1 we will call this value X. X=20010(3)(8010n6/256)=62,500 slk, cycles Hence 200ms=62,500 clk, cycles. To make OC1RS- OC1R =62,500 clk cycles , We need to make OC1R some value >0, so we will make OC1R= 1 and OC1RS =62,501. Now OC1RS-OC1R = 62,5011=62,500 Hence OC1R =1 OC1RS =62,501 You will set the ISR Routine of OC1 to turn on the LED at RA0. Because this is a Single Pulse, this will Interrupt will run only once. You do not need to include any \#pragma compiler directive (the DEVCFG initial setup)

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

Mastering Big Data Interview 751 Comprehensive Questions And Expert Answers

Authors: Mr Bhanu Pratap Mahato

1st Edition

B0CLNT3NVD, 979-8865047216

More Books

Students also viewed these Databases questions

Question

The models used to analyse different national cultures.

Answered: 1 week ago

Question

The nature of the issues associated with expatriate employment.

Answered: 1 week ago