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
Use the 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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F7f5d7e33-a769-491d-918b-b3ccb8916743%2F00c6177a-a4b7-449a-9cb6-8bd20ea8aa42%2Ffv8papt_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)