??? 04/10/07 08:38 Read: times |
#136893 - C timing loops Responding to: ???'s previous message |
Erik Malund said: I2C coding does not require strict timing.
true, However, what about when you happen to grab a SMB chip? Eric, the point that I was trying to make was: The timing constraints of a 24Cxx type chip running at 5V are all >600nS except for START conditions that are >1300nS (from memory). Therefore a 12MHz 8051 only has to worry about ensuring the 1300nS time. If you are using different chips, then you ensure that you satisfy all conditions. Writing "timing loops" in C is semantic. If you want an accurate time then you use a hardware timer. Your loop consists of waiting for the timer. You can set this up in C. A software "timing loop" of counting instructions will obviously depend on the C compiler. Most compilers will allow some inline assembly. The inner loop would be inline asm that is called by C. The C overhead of calling a 1mS delay 10000 times to implement a 10 second delay is fairly immaterial. David. |