Hi,
Please send me example code for MSP430G2231 to generate 2 minutes of delay.
Ex; The micro reads an input in say analog pin1. I need a code that execute high on other pin after 2 minutes have expired.
Thanks,
Sanjay
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.
Hi,
Please send me example code for MSP430G2231 to generate 2 minutes of delay.
Ex; The micro reads an input in say analog pin1. I need a code that execute high on other pin after 2 minutes have expired.
Thanks,
Sanjay
You can also use __delay_cycles(1000 * Freq_In_Mhz) to generate 1 millisecond delay.
Suppose you are running CPU at 8 MHz then code will be
#define CONTROLLER_FREQ 8 // 8 MHz
#define DELAY_NO_OF_SECOND 60 * 2 // 2 Minutes
long i = 0;
for(i=0; i < (DELAY_NO_OF_SECOND*1000); i++)
{
__delay_cycles(1000 * 8);
}
No Crystal:
Use 1MHz dco, smclk div-by-8, timer div-by-8
1'000'000 /8 /8 = 15625 ticks a second
(max in a 16bit) 65535 /15625 = 4.19424
rounded down, the slowest you can get is 4 seconds.
So make the timer irq count down a counter that starts at 30, and when it reaches 0 wake-up main with:
__bic_SR_register_on_exit(LPM0_bits);
P.S alternative is to use WDT, as it's 15bit slowest you can get is 2sec but is easier to set up.
**Attention** This is a public forum