Hello all,
I am sitting here at my first embedded position trying to get up to speed with a very aggressive schedule. I have a few beginner's book on embedded system ( An Embedded Software Primer and Practical Statecharts in C/C++: Quantum Programming for Embedded Systems ), but my current problem is that I need to implement a configurable timer/clocking mechanism to be used as a trigger. From the requirements that I have there are specs that are similar to the following... // Semi type of requirements structure.... Initialization of the device shall be started. Wait for an Ack from the device If the device doesn't send an Ack within 5 seconds a failure shall be determined. Throughout the requirements there are numerous requirements for a time-out period, but I need to develop a nice programmable timer/clocking mechanism. The project has a simple scheduler that another developer has create that is calls our various subsystems that need to be called every 12.5 Hz or 10 Hz ( or whatever the requirement states ). Initially I was thinking of housing a simple count variable within the subsystem that increments the count variable and when it reaches the threshold value it would indicate that the elapsed time has expired. I don't really like this approach since this approach will have to be sprinkled throughout the code and perhaps more than once within a subsystem. I was thinking of creating a common timer mechanism that has a resolution of about 50 or 100 ms ( since most elapsed time-out periods are 1 to 5 seconds ) that when a subsystem needs a time-out timer it would pass in the Time-out Period and a call back function. So it would look something like // I think this prototype if correct, but correct me if I am wrong addTimeout( int timeOutPeriodInMs, void (*func)(void) ) Then within the Timeout module it would keep track of the time-out periods and when one has expired it would call the callback function. I am at a lose of how to correctly implement this. I have some ideas, but I don't know if they will work and I don't have a lot of time to test it. The chip that I am using is the Motorola ( now Freescale ) MCF5282 IC. Any help is GREATLY appreciated. Thanks
Mark