|
|
View previous topic :: View next topic |
Author |
Message |
theasus
Joined: 31 May 2009 Posts: 79
|
Which code is more correct? |
Posted: Mon Aug 17, 2009 2:59 am |
|
|
I tried these codes on CCS-C and two of them have worked. But I don't know which is more correct?
1)
Code: | #include <12F675.h>
#use delay(internal=4M)
#fuses NOWDT,INTRC_IO,PUT,NOPROTECT,BROWNOUT,NOMCLR,NOCPD |
2)
Code: | #include <12F675.h>
#use delay(clock=4000000)
#fuses NOWDT,INTRC_IO,PUT,NOPROTECT,BROWNOUT,NOMCLR,NOCPD |
|
|
|
Ttelmah Guest
|
|
Posted: Mon Aug 17, 2009 5:11 am |
|
|
Why does there have to be a 'more correct' version?....
Both will produce exactly the same output.
It is a bit like asking whether it is 'more correct' to use a for...next loop, or a while loop. No difference at all.
The bottom one, will be accepted by a wider 'range' of compilers (the top one only by more recent ones). The top one makes it easier to avoid errors (it is quite easy with the '4000000' notation to 'miscount' the number of zeros by one). The top notation, was introduced, since especially with really large frequencies (48MHz etc.), it becomes hard to count all the zeros,and ensure the value is 'right'.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|