So if is it possible I want to replace the 0.5 sec by 2 minutes ( for example )
( I said N minutes because that's related to the user that he will be able to send it through VB interface using Serial port communication )
I won't use the delay_ms because it will be imprecise
I really need some help !! :-|
Thanks
For quartz 4MHz vs TMR1 maximum possible delay is 524,28ms
But you can make variable counter, for example i:
Code:
while(1) {
//procedure setting timer1 (tmr1h tmr1l = 62500)
if(TMR1IF) { i++; TMR1IF = 0;} // I'm not sure for this in CCS
if (i == N) { // where N - time in seconds
PIN_A1 = !PIN_A1;
i = 0;
}
}
i++; TMR1IF = 0;
if (i == N) { // where N - time as a multiple of 524,288 ms
PIN_A1 = !PIN_A1;
i = 0;
}
Moving the above segment to the ISR lets you multitask - do something else while waiting for the timer to overflow. For that, you also need to set the interrupts, so