I'm new on using this platform, so i need some help..
i'm looking for a logic to make a delay fuction to work on current metering...
i saw somewhere that i'll need use timer, but i dont have much knowledge...
someone can help me?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I'm new on using this platform, so i need some help..
i'm looking for a logic to make a delay fuction to work on current metering...
i saw somewhere that i'll need use timer, but i dont have much knowledge...
someone can help me?
That is pretty vague description of what you need it to do.
You want to use a msp430 who's only job is to read a pin and with a delay output a signal on a different pin?
There are Reset IC's that do just that:
http://www.mouser.com/Semiconductors/Power-Management-ICs/Supervisory-Circuits/_/N-wnws/?Ns=Pricing|0
or you want to add a timer delay your current-metering software that is running on a msp430?
the delay function will be used to temporarily stop sampling values from ADC12 in a vector inside a loop. Understand? i think that i'll need use timer, if not, implement a function which waits for certan amount of microseconds (notmiliseconds).
something like this
void watiMicroseconds(int microseconds)
{
????
}
How can I do that?
You mean delay in time, of course.
One way to do it is to make the CPU execute useless and harmless instruction for the desired interval of time. There is an intrinsic function called __delay_cycles(literally a #); The CPU executes instruction at the rate of the CPU clock (called MCLK) which can vary. Thus you need to know the frequency of MCLK you are using. If it is 8 MHz, for example, and then __delay_cycles(8000000); will cause a 1 sec delay, while __delay_cycles(16000); will cause a 2 msec delay. Note that if interrupt and/or DMA are enabled, they may cause additional delays on top of the __delay_cycles(#).
A different way to cause delay is to use a Timer which almost every MSP430 chip has at least one. These Timers do not know time either; they count other kinds of clock cycles (called SMCLK, ACLK, or INCLK). You can program the Timer to count the clock cycles and raise a flag that can also generate an interrupt. In the case of interrupt, the CPU can do other useful things or go to sleep while waiting. In the case of just the flag, the CPU can check the flag periodically. Other interrupts and DMA will not cause additional delays directly in either case, but the time required checking the flag or enter and execute the ISR are always added to the delay.
**Attention** This is a public forum