Question 2 Write a C language program for the EVBPIus2 evaluation board that use
ID: 663104 • Letter: Q
Question
Question 2 Write a C language program for the EVBPIus2 evaluation board that uses an interrupt service routine to read the analog value on pin PEO every 0.3ms. Write this value to the PORTB LED?s. Your program should be sufficiently complete to compile and run on the EVB Plus 2 evaluation board. Use good programming practice (comments, self-documenting variable names, functions etc.) to make your code more ?readable?. As in the laboratory, you can assume that register and interrupt service routine definitions are provided for you in header files named 106811 .h and 1NT68 11 .h respectively. Your C code should be as simple as possible. [30]Explanation / Answer
CONCEPT:
C program to use Routine Interrupt Service
CODE:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<iostream>
#include<math.h>
//Chip Settings
__CONFIG(1,0x0200);
__CONFIG(2,0X1E1F);
__CONFIG(3,0X8100);
__CONFIG(4,0X00C1);
__CONFIG(5,0XC00F);
unsigned char counter=0;
void main()
{
//Setup Timer0
tyop=1; // is divide by 256
tyop1=1;
tyop2=1;
psd=0; //Timer Clock Source
ticf=0;
t689f=1; //8 BIT MODE
t6rye=1;
poiju=1; //Enable Peripheral Interrupt
GIE=1; //Enable INTs globally
trmeio=1;
//Set RB1 as output because we have LED on it
TRISB&=0B11111101;
while(1);
interrupt ISR();
printf(
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.