Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/08/07 04:31
Read: times


 
#140393 - How To Do Timed Activity Process
Responding to: ???'s previous message
Jay:
You are on the right start with the process for timing the readings. Indeed setup your timer routine for the desired 10mec repetition rate. Let me describe one way to make the pressure sensor reading logic work. At each 10msec timer interrupt have that set a bit flag in the BIT memory area. That is all that interrupt service routine would need to do. Now in the main program loop have a check of this bit flag. If you see it set then have the main loop call a subroutine which launches the command sequence to make an I2C read of the pressure transducer value and also clears the timing bit flag. If you are using an I2C peripheral function to handle the traffic on the SCL and SDA lines and you are using interrupts from that peripheral that occur after each byte is transfered then just service those events in their own normal interrupt service routine. Often the end of an I2C transaction is determined by a sequence of the I2C device interrupts. This completed state could post another bit flag variable to the mainline code to indicate that the pressure transducer reading has completed and is available for use.

Obviously with this scheme you have to ensure that you get the pressure transducer reading process on the I2C bus finished in less than 10msec of time.

Another way to do this could be to have the 10msec timer interrupt routine call the routine that launches the pressure transducer reading - but that is only advisable if you are indeed using some I2C peripheral hardware on your MCU. The setup process to start such a peripheral to begin a bus transaction is a short subroutine that does not take very much time. Such setup is very reasonable to do directly from inside the timer service routine. On the other hand if you are using bit-banged I2C transfers or polling the byte completes without using interrupts then the I2C handling should be confined to code executed from the main code thread.

Michael Karas


List of 4 messages in thread
TopicAuthorDate
handling one interrupt from other interrupt handle            01/01/70 00:00      
   You Do Not            01/01/70 00:00      
   How To Do Timed Activity Process            01/01/70 00:00      
      thanks            01/01/70 00:00      

Back to Subject List