Answered step by step
Verified Expert Solution
Question
1 Approved Answer
calculate pi in C using gregory leibniz for MSP432 Here's given code. #include msp.h #include math.h /**************************************** * SysTick Timer Init ***************************************/ void SysTick_Init(void){ SysTick->LOAD
calculate pi in C using gregory leibniz for MSP432
Here's given code.
#include "msp.h" #include "math.h" /**************************************** * SysTick Timer Init ***************************************/ void SysTick_Init(void){ SysTick->LOAD = 0x00FFFFFF; // maximum reload value SysTick->CTRL = 0x00000005; // enable SysTick with no interrupts } // Need to change the timer function to read value instead of delaying void SysTick_Wait(uint32_t delay){ SysTick->LOAD = (delay - 1);// count down to zero SysTick->VAL = 0; // any write to CVR clears it and COUNTFLAG in CSR while(( SysTick->CTRL&0x00010000) == 0){}; } /************************************* * Launchpad init ************************************/ void LaunchPad_Init(void){ P1->SEL0 &= ~0x13; P1->SEL1 &= ~0x13; // 1) configure P1.4 and P1.1 as GPIO P1->DIR &= ~0x12; // 2) make P1.4 and P1.1 in P1->DIR |= 0x01; // make P1.0 out P1->REN |= 0x12; // 3) enable pull resistors on P1.4 and P1.1 P1->OUT |= 0x12; // P1.4 and P1.1 are pull-up } #define pi 3.14159265359 char n[30], q[30], tex[30], ts[30]; float var, dif, t_is; //double var, dif, t_is; uint32_t j, k; /************************************* * main.c *************************************/ void main(void) { LaunchPad_Init(); SysTick_Init(); P1->OUT = 0x00; while(1){ var=0; for(){ //Gregory-Leibniz algorithm } // Read value from timer P1->OUT ^= 0x01; //LED toggle // TODO: Error Calc compare result with pi // Reading Counter Value into k // t_is = k; // t_is *= 8; t_is /= 32768; //Count in seconds } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started