Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I. OBJECTIVES: Embedded systems use a watch dog timer to recover from program malfunctions. During faulty software operations ( e . g . a program
I. OBJECTIVES: Embedded systems use a watch dog timer to recover from program malfunctions. During faulty software operations eg a program gets stuck in an infinite loop expiration of a watchdog timer causes the system to reboot. In embedded applications, these timers can be implemented in either software or hardware. This assignment teaches students on how to implement a watchdog timer in software. Copy files for this exercise from coursescs s hefeiqiump to your cs mp directory. You will use timing functions provided in timepacksapc.c II Operations of a Watchdog Timer: One can imagine if an embedded system installed in a remote area goes haywire, it may be impossible or very costly to send a service personnel to reset the system. See an example application on the NASA Deep Space Probe and a more recent one on the Mars helicopter flight. A watchdog timer can automatically reset the system without human intervention in the event of a system failure. In theory, a watch dog timer is a timer that is set to expire at a predetermined time interval. During a faulty condition eg software is stuck in an infinite loop timer expiry reboots the entire system. If the watchdog timer is implemented in external hardware, its logic will send a signal to the reset circuit eg power up restart of the embedded system when the timer expires. If implemented in software, the internupt service routine of the timer will run a reboot function that restarts the application from scratch. Since rebooting an application causes a major interruption to the operation of the system similar to the powering up your computer you don't want to reboot it if this is not needed. In most cases, we don't know exactly when the problem will occur, but we may have some estimate on the time when the problem will likely to occur. Then you set the watchdog timer to expire at or a little after that estimated time. For those times that the software is nunning without fault, you reset the watchdog timer before it expires to prevent internupt from happening. This action is known as "kicking the dog" III. Software implementation of a Watchdog timer: a Part : Simulating the coding problem: We use a similar test set up as in mp The test program for this m p is charGenl.c and is provided in the cs mp directory. scp the file to your vserver VM and build the charGen executable at the vserver V using: gec charGenl charGenlic Build the software application watchdog.lnx on users.csumb.edu pe using the provided makefile, watchdog.c reboot.s and timepacksapc.c files. scp the watchdog. ln x to your vserver VM and load it into the tutor VM using mtip and d Run the programs in this sequence: i Start the watchdog.lnx using tutor command: go ii Open up a remote ssh window at vserver V M and nun charGenl to generate test characters to COM at second intervals using: sudo JcharGenl use cs as your sudo password The provided code in watchdog.c will print out characters received from the charGen driver. After characters, the system will get stuck in a simulated infinite loop and no characters will be printed out. However, the serial port interrupts are ongoing. The program continues to execute the serial port ISR and process the received characters, but the main is not printing them out. Capture a run of your program in the tutor VM with a typescript file named scriptpartb Part a: Reset the system using a watchdog timer Code the watchdog timer using functions provided in timepacsapc.c Set the count value to generate an interrupt every mse this is longest duration between interrupts you can with a bit counter hardware When the watch dog timer expires, the ISR calls a reboot function the provided reboot.s that restarts the watchdog.lnx program. If you want to wait longer time to do reboot you have to modify the ISR software as follows: void irqinthandc tickcount ; if tickcount reboot ; this will do reboot every ms void irqinthandco tickcount; if tickcount reboot ; this will do reboot every ms Cat your programs watchdogc timepacksapc.c and reboot.s and capture the run of your program in the tutor VM with a typescript file named scriptpart a c Part b: Implement the "Kick the dog" function In watchdog.c at the end of the dowork function, implement a kickdogO to call the settimercount function to reset the count back to This will prevent the timer from expiring under normal circumstances. If the program gets stuck in the middle of dowork and kickdogO is not run, then the timer will expire and the program will get rebooted at the timer ISR. Cat your programs watchdogc timepacksapc.c and reboot.s and capture the run of your program in the tutor VM in a typescript file named scriptpartb Any private functions or variables you need should be declared static in "timepacksapc.c so that the calling program can never accidentally use a variable or function with the same name, or interfere with yours.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started