tajiknomi
Member level 4
I want to know how can I calculate the reasonable time taken by the module in real time. Here is an interrupt module for which I want to calculate the time.
I will be using a 4Mhz oscillator as a clock and as PIC MCU take 4cycles for "most" of the simple statements so one statement would require almost 1us. (Correct me if i am missing something). I have wrote the program in C therefor it is quite difficult for me to know which statement(s) would require how much cycles.
Here is the module for which i want to calculate time. Another thing which i want to mention i.e. "Delay" in the interrupt routine is quite a wierd thing and i want to ignore it. Should i put the flag in ISR and then come back to the MAIN() to execute my delay ? Or shoud i execute the whole ISR in the main function and just identify the interrupt in the vector section ? What would be the best way and why ?
I would be glad if someone can direct me. Thank you
I will be using a 4Mhz oscillator as a clock and as PIC MCU take 4cycles for "most" of the simple statements so one statement would require almost 1us. (Correct me if i am missing something). I have wrote the program in C therefor it is quite difficult for me to know which statement(s) would require how much cycles.
Here is the module for which i want to calculate time. Another thing which i want to mention i.e. "Delay" in the interrupt routine is quite a wierd thing and i want to ignore it. Should i put the flag in ISR and then come back to the MAIN() to execute my delay ? Or shoud i execute the whole ISR in the main function and just identify the interrupt in the vector section ? What would be the best way and why ?
Code:
void interrupt(){
if (INTCON.RBIF){
char tmp; // PORTB Change Interrupt ??
if((KEYPAD_DATA & 0xF0) != 0XF0){ // Check to see that it is TRUE INTERUPT ( i.e. Falling Edge Interrupt)
char i;
[B]delay_ms(20);[/B] // Avoid debouncing
tmp=0x10;
for(i=0;i<4;i++){ // Find the row
if((KEYPAD_DATA & tmp) == 0x00)
{row=i;break;}
tmp=(tmp<<1);
}
KEYPAD_DATA=0X01;
for(i=0;i<4;i++){ // Find the column
if((KEYPAD_DATA & tmp) == tmp)
{colum=i;break;}
KEYPAD_DATA=(KEYPAD_DATA<<1); //01,10,100,1000
}
tmp=array[row][colum];
LCD_character_write((tmp+48));
KEYPAD_DATA=0x00; // Clear DATA PORT
}
tmp=KEYPAD_DATA; // MUST Read KEYPAD_DATA, otherwise flag will not clear
INTCON.RBIF = 0; // Clear the flag
}
}
I would be glad if someone can direct me. Thank you