hukiju
Newbie level 6
Hi all,
I have a PIC18F4550 with oscillator crystal 20MHz (C Compiler), I would like to understand more on how to calculate 1 second delay from this 20MHz.
Refering to thread (https://www.edaboard.com/threads/193407/), Post #6,
---------------------------------------------------------------------------------------------------------
Hi,
For having an approximately 1 second delay i've ued a delay function same as the following:
In a C compiler for PIC (PIC18F4550-selected frquency 48MHz) the 1 second delay function is as below:
void delay (void){
unsigned long i;//(long in this compiler is 4 Bytes)
for(i = 0;i<1000000;i++);
}
---------------------------------------------------------------------------------------------------------
He mentioned that he is using PIC18F4550-selected frquency 48MHz and his 1 second delay function is:
void delay (void){
unsigned long i;//(long in this compiler is 4 Bytes)
for(i = 0;i<1000000;i++);
}
How do he know that he need to loop for 1000000 times to get 1 second delay?
Appreciate for any help given!
Thanks
Lee
I have a PIC18F4550 with oscillator crystal 20MHz (C Compiler), I would like to understand more on how to calculate 1 second delay from this 20MHz.
Refering to thread (https://www.edaboard.com/threads/193407/), Post #6,
---------------------------------------------------------------------------------------------------------
Hi,
For having an approximately 1 second delay i've ued a delay function same as the following:
In a C compiler for PIC (PIC18F4550-selected frquency 48MHz) the 1 second delay function is as below:
void delay (void){
unsigned long i;//(long in this compiler is 4 Bytes)
for(i = 0;i<1000000;i++);
}
---------------------------------------------------------------------------------------------------------
He mentioned that he is using PIC18F4550-selected frquency 48MHz and his 1 second delay function is:
void delay (void){
unsigned long i;//(long in this compiler is 4 Bytes)
for(i = 0;i<1000000;i++);
}
How do he know that he need to loop for 1000000 times to get 1 second delay?
Appreciate for any help given!
Thanks
Lee