Use the C programming language, not C++. #include “driverlib.h” #include #include   #define MAXCOUNT 500 Bool isPrime(uint16_t x); // Main Function Void main(void){       volatile uint16_t ii; // declare local loop variable       // Halt the WDT and unlock PMM for Port I/O Configuration     WDT_A_hold(WDT_A_BASE);     PMM_unlockLPM5();       //Set P1.0 (RED LED) as Output     GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);       //Set P1.0 (RED LED) Low -- Turns RED LED OFF     GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);       for(ii=0; ii

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

 

Use the C programming language, not C++.

#include “driverlib.h”

#include <stdint.h>

#include <stdbool.h>

 

#define MAXCOUNT 500

Bool isPrime(uint16_t x);



// Main Function

Void main(void){

 

    volatile uint16_t ii; // declare local loop variable

 

    // Halt the WDT and unlock PMM for Port I/O Configuration

    WDT_A_hold(WDT_A_BASE);

    PMM_unlockLPM5();

 

    //Set P1.0 (RED LED) as Output

    GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);

 

    //Set P1.0 (RED LED) Low -- Turns RED LED OFF

    GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);

 

    for(ii=0; ii<MAXCOUNT; ii++){

    if(isPrime(ii)) GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);

    }

    while(1); // Spin Loop

}

 

// Function isPrime

// Input x -- number to check if prime

// Returns: True, if x is prime else FALSE

//

 

Bool isPrime(uint16_t x){

    volatile uint16_t ii;

    uint16_t maxValue;

   

    if((x==0) || (x==1)) return false;

    if((x==2) || (x==3)) return true;

 

    maxValue = (x/2) + 1; // doesn’t hurt to add parenthesis

 

    for(ii=2; ii<= maxValue; ii++){

    if((x % ii) == 0) return false;

    }

return true;

}

Modify the in-class code to count the number of primes from
1 to 500*(1+2*i) with i = 0 to 10.
Your code does NOT need to toggle LED1.
You should also measure the number of clock cycles needed for
each value of i.
Transcribed Image Text:Modify the in-class code to count the number of primes from 1 to 500*(1+2*i) with i = 0 to 10. Your code does NOT need to toggle LED1. You should also measure the number of clock cycles needed for each value of i.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY