Question

If you want to have a 4 second delay and you have configured SysTick to create...

If you want to have a 4 second delay and you have configured SysTick to create 0.2 second delay, how do you get a 4 second delay in software?

Answer in C code.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
  • SysTick is a timer which generates an interrupt after the configured time delay and the controls goes to the SysTick_Handler function.
  • As per the question, the SysTick is configured for 0.2 seconds, after every 0.2 seconds the control of the CPU(Microcontroller) goes to the SysTick_Handler function.
  • There are multiple ways to generate 4 seconds delay using 0.2 second configured SysTick timer. The common approach is to use a global variable tickCount and incrementing it for each 0.2 second(when controls goes to SysTick_Handler).
  • For generating 4 second delay, the tickCount variable can be monitored for its value. Whenever the tickCount value is 20 (4 seconds / 0.2 second = 20) or multiple of 20, then the 4 second delay is generated.
  • From the code, it is understood in better way.
  • Please note that, based on the different microcontroller, you may need to setup 0.2 second SysTick differently.
  • The program is for understanding purpose.

C Code:

#include "LPC17xx.h"
  
volatile uint32_t tickCount = 0; /* Variable to count 0.2 seconds ticks */
  
/* Interrupt Hanlder of SysTick for 0.2 seconds */
/* The control of the program comes to this function after each 0.2 second */
void SysTick_Handler(void) {   
tickCount++; /* See startup file startup_LPC17xx.s for SysTick vector */
}

void dealy_4_Second(void){
/* Waiting for the 20 tickCount, for 4 seconds and control will be inside while loop */
while(tickCount%20);
}

int main (void) {
/* Configuring SysTick for 0.2 = 200 milliseconds */
uint32_t sysConfigReturn;
sysConfigReturn = SysTick_Config(200*SystemCoreClock / 1000);
/* Code before delay */
delay_4_Second();
/* Code after delay */
  
while(1); // continuous loop
return 0;
}

Add a comment
Know the answer?
Add Answer to:
If you want to have a 4 second delay and you have configured SysTick to create...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Write code to turn on bit 4 of PORTC, where bit 4 is configured as...

    1. Write code to turn on bit 4 of PORTC, where bit 4 is configured as output bit. 2. What does this code in assembly do? You can write your answer in a high-level language like C. MOVF Q,W SUBWF P,F

  • You want to create a portfolio equally as risky as the market, and you have $500,000...

    You want to create a portfolio equally as risky as the market, and you have $500,000 to invest. Information about the possible investments is given below:   Asset Investment Beta   Stock A $ 85,000       .80         Stock B $165,000       1.15         Stock C 1.40         Risk-free asset a. How much will you invest in Stock C? (Do not round intermediate calculations and round your answer to 2 decimal places, e.g., 32.16.) b. How much will you invest in the risk-free...

  • You want to create a portfolio equally as risky as the market and you have $1,300,000...

    You want to create a portfolio equally as risky as the market and you have $1,300,000 to invest. Given this information, fill in the rest of the following table: Shows all the step and formula. Don't round off until you get the answer. Asset Investment Beta Stock A 184000 0.81 Stock B 437000 1.22 Stock C 1.65 Risk-free asset

  • You want to create a portfolio equally as risky as the market, and you have $500,000...

    You want to create a portfolio equally as risky as the market, and you have $500,000 to invest. Information about the possible investments is given below:   Asset Investment Beta   Stock A $ 144,000       .89         Stock B $ 136,000       1.34         Stock C 1.49         Risk-free asset 1. How much will you invest in Stock C? (Do not round intermediate calculations. Round your answer to 2 decimal places (e.g., 32.16). 2. How much will you invest in the risk...

  • ou want to create a portfiolio equally as risky as the market, and you have $500,000...

    ou want to create a portfiolio equally as risky as the market, and you have $500,000 to invest. Information about the possible investments is given below Asset Stock A 120,000 Stock B 150,000 Stock C Risk-free asset Investment Beta 80 1.15 1.40 Requirement 1: How much will you invest in Stock C? (Do not round intermediate calculations. Round your answer to 2 decimal places (e.g., 32.16).) Investment in Stock C Requirement 2: How much will you invest in the risk-free...

  • You want to create a portfolio equally as risky as the market, and you have $1,000,000...

    You want to create a portfolio equally as risky as the market, and you have $1,000,000 to invest. Given this information, fill in the rest of the following table: (Do not round intermediate calculations and round your answers to 2 decimal places, e.g., 32.16.) You want to create a portfolio equally as risky as the market, and you have $1,000,000 to invest. Given this information, fill in the rest of the following table: (Do not round intermediate calculations and round...

  • You want to create a portfolio equally as risky as the market, and you have $500,000...

    You want to create a portfolio equally as risky as the market, and you have $500,000 to invest Information about the possible investments is given below: Asset Investment Beta $142.000 $138,000 Stock A 87 Stock B Stock C 1.32 1.47 Risk-free asset How much will you invest in Stock C? How much will you invest in the risk-free asset? (Do not round intermediate calculations and round your answers to 2 decimal places, e.g., 32.16.) Investment in Stock C Investment in...

  • You want to create a portfolio equally as risky as the market, and you have $500,000...

    You want to create a portfolio equally as risky as the market, and you have $500,000 to invest. Information about the possible investments is given below: Beta 76 Asset Investment Stock A $ 131,000 Stock B $149,000 Stock C Risk-free asset 1.21 1.36 How much will you invest in Stock C? How much will you invest in the risk-free asset? (Do not round intermediate calculations and round your answers to 2 decimal places, e.g., 32.16.) Investment in Stock C Investment...

  • You want to create a portfolio equally as risky as the market, and you have $500,000...

    You want to create a portfolio equally as risky as the market, and you have $500,000 to invest. Information about the possible investments is given below: Beta .80 Asset Investment $ 85,000 Stock A Stock B $165,000 Stock C Risk-free asset 1.40 a.How much will you invest in Stock C? (Do not round intermediate calculations and round your answer to 2 decimal places, e.g., 32.16.) b.How much will you invest in the risk-free asset? (Do not round intermediate calculations and...

  • Suppose we have a second order open system. K=1 T1=1 T2=12 with a delay of 3...

    Suppose we have a second order open system. K=1 T1=1 T2=12 with a delay of 3 seconds with proporcional regulator which has a koeficent (kp=12). A) Draw and comment the characteriscit log and amplitudes (KLA) and characteristic log and phase (KLF) B) If posible to get me started how to plot on matlab it would be great. thank you very much for your help

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT