Class7

Embedded Real Time Software
Development
Week 7
Review, Quiz, & Watchdog Timers
ENTC-489 Embedded Real Time Software Development
Today’s Agenda
• Announcements
• Review
– Real World I2C Timing Examples
• Quiz
• Watchdog timers in Embedded Systems
ENTC-489 Embedded Real Time Software Development
Announcements
• In recognition of the need to work during spring break,
WDT Extra Credit Program, it will now replace two lowest
Quiz/Homework grades
• Extra credit assignment will be handed out after the quiz
which may replace lowest Quiz/Homework grade
• If you turn in both, you get a do-over on a total of 3 grades!
• Mid-term exam (25% of your grade) is the week after spring
break.
– Open book (should have calling information on µC/OS and
IQmathLib functions handy)
– Calculator recommended
– Anything covered in my lectures is fair game!
ENTC-489 Embedded Real Time Software Development
Overall View of Intensity Running
Low = In
Idle Task
Measure
Temperature
& Humidity
Delay
ENTC-489 Embedded Real Time Software Development
Code to Get 1mS Time Delays
ENTC-489 Embedded Real Time Software Development
Zoom on Reading Temperature
Read Temp
Command
NAKed
Read
ACK, Read Data, Start
Humidity Reading
ENTC-489 Embedded Real Time Software Development
Read Temperature Loop
ENTC-489 Embedded Real Time Software Development
Read Command with Delayed Stop
• Start of command based on OSTimeDly() and there
are not many higher priority processes so the time
is very close to the time set by OSTimeDly() we use
for the stop bit generation.
ENTC-489 Embedded Real Time Software Development
Delay
varies
Service
Timer
Interrupt
Delay Before Stop
ENTC-489 Embedded Real Time Software Development
Sending Read Temp Command
Service
Timer
Interrupt
Address
+ Write
Bit
Read Temp
Command
ENTC-489 Embedded Real Time Software Development
Service I2C
Interrupt
Command to Read Temperature
Read 2 Bytes
ENTC-489 Embedded Real Time Software Development
Generic Read Command
ENTC-489 Embedded Real Time Software Development
Waiting for the Conversion
Timer
Interrupt
Service
Address
+ Read
Bit
SHT21
NAKs
Command
Extra
from uC
port
I2C
Interrupt
Service
ENTC-489 Embedded Real Time Software Development
Stop Bit
Sent
Reading Before Conversion Done
Returns 0
Because of
Command
NAK
ENTC-489 Embedded Real Time Software Development
Got the Conversion
Address
+ Read
Bit
ACK
High
Order
Byte
Start of
Humid
Cmd
Low
Order
Byte
ACK
from uC
Stop
from uC
Service
I2C IRQ
ENTC-489 Embedded Real Time Software Development
Successful 2 Byte Read
bytes_in 0, then 1
maxbytes = 2
ENTC-489 Embedded Real Time Software Development
Break/Quiz
ENTC-489 Embedded Real Time Software Development
Kernel Watchdog Timer
• What is a WDT?
• Why do I need one?
• How is a Kernel WDT different than a
hardware WDT?
• Basic WDT Architecture
ENTC-489 Embedded Real Time Software Development
What is a WDT?
• An independent, usually hardware mechanism
to monitor the health of a software based
system.
• Based on the principle of check in (often
called a tickle) by software on a periodic basis
• If the software fails to tickle in the required
time a hardware reset is issued
ENTC-489 Embedded Real Time Software Development
Why do I need a WDT?
• Unanticipated events can cause the software to
go crazy
–
–
–
–
Rare interrupt for which there is no handler
Undetected software bug
High energy sub-atomic particle (rare on earth)
Hardware (latch-up is moderately common) causes
I/O pins to have unanticipated values
• WDT allows you to at minimum
– Put hardware in a safe condition
• WDT may allow you to correct or work around
the problem
ENTC-489 Embedded Real Time Software Development
How is a Kernel WDT Different
• H/W WDT
– Usually short timeouts (< 1 second to << 1 second)
– Likelihood ALL the software is confused (no kernel)
– Always results in a reset, which can be a booger to debug
• Kernel WDT
– Timeout often set to > 1 second, depending on what the
tasks are doing and the criticality of the tasks
– Likelihood that only one task is malfunctioning, allowing
system to operate with a limp
– Health task can allow breakpoints when timeouts do occur,
making debug a little easier
ENTC-489 Embedded Real Time Software Development
Health Task Architecture
• All task pends must have a timeout < the required check-in time
• Health task must tickle the H/W WDT when everything is good
• Health task may delete and re-create tasks that do not check-in on
time
ENTC-489 Embedded Real Time Software Development