5

I Quote from Wikipedia:

A watchdog timer (WDT; sometimes called a computer operating properly or COP timer, or simply a watchdog) is an electronic timer that is used to detect and recover from computer malfunctions.

While using STM32F429I-Discovery, I came across a term [in "stm32f4xx.h"] which uses a register to disable Watchdog:

#define  ADC_CR1_AWDIE    ((uint32_t)0x00000040)    //Analog Watchdog interrupt enable

Here, I am unable to understand Analog Watchdog

And if possible,

#define  ADC_CR1_JAWDEN    ((uint32_t)0x00400000)    //Analog watchdog enable on injected channels

What is injected channel here?

smoe
  • 500
  • 3
  • 13
user263210
  • 417
  • 1
  • 5
  • 16

2 Answers2

13

A watchdog timer can be thought of as two separate circuits, a timer circuit and a watchdog circuit. The timer circuit merely counts the time that passes. The watchdog circuit actively monitors the timer to see if a certain amount of time has passed without being reset by software. If so, the software is no longer running and the watchdog typically performs an automated function such as resetting the processor. The watchdog needs only to be told at initialization how much time to monitor for and it handles the rest of its operation without additional software interaction.

An analog watchdog operates in a similar manner. Only instead of monitoring a timer, it monitors an analog input channel. At initialization, you tell the watchdog what analog thresholds to monitor for. If a converted value on an analog input passes one of these thresholds, it will fire an interrupt for you to process the signal sample. This means you don't have to write code to continuously poll the analog inputs and check their levels. It is all handled autonomously in the background by the analog watchdog circuitry.

An injected channel can just be thought of as a high priority conversion channel. If a regular analog input is in the middle of performing a conversion and a conversion is triggered (either by a timer or because it is programmed in continuous conversion mode) on an injected channel, the conversion on the regular channel will halt and wait while the injected channel is converted before completing its own conversion. This is useful if you have an analog input that must be responded to in a realtime manner.

Here is an application note (which, for some strange reason, doesn't seem to be available in ST's website) that give a few examples of the use of the various ADC features. And here is another explanation of the two features your question was about.

rel
  • 764
  • 5
  • 18
embedded.kyle
  • 10,976
  • 5
  • 37
  • 56
  • 1. So WatchDog isn't only for checking the unresponsive processor and resetting it. There are other WatchDog(s) which can be used for watching different actions happening to processor (i.e. checking analog input threshold). 2. Injected channel provides the WatchDog (or some other function of processor of same type) the real-time conversion channel it needs. Am I correct? – user263210 Aug 06 '14 at 18:22
  • @embedded.kyle : The analogue watchdog does not trigger a conversion, rather it is itslef triggered by a conversion exceeding the threshold conditions. – Clifford Aug 06 '14 at 18:50
  • 1
    @user263210 : At this point you should be reading the [Reference Manual](http://www.st.com/web/en/resource/technical/document/reference_manual/DM00031020.pdf) (section 13 specifically). SO is not the manual. The [STM32F4xx Standard Peripheral Library](http://www.st.com/web/en/catalog/tools/PF257901) will also be useful - it has examples for all peripherals. Alternatively you might try the STM32Cube tool (same link), which includes the library and a lot more besides. The watchdog can work on injected or regular channels - normally you would use *continuous conversion mode* – Clifford Aug 06 '14 at 18:55
  • 2
    @user263210 1. A watchdog is a generic term for a type of circuit that monitors another circuit. It could be an external chip or circuit. Many processors have on-chip watchdog timers. The STM32F01xxx has a watchdog clock, an analog watchdog, an independent watchdog, and a window watchdog. Information on what each monitors can be found in the reference manual cited by Clifford. 2. The injected channels don't provide the watchdog. The watchdog circuitry can monitor any of the regular or injected channels' conversions and trigger an interrupt based on the programmed thresholds. – embedded.kyle Aug 06 '14 at 20:00
  • @embedded.kyle : I was searching for Watchdog disabling register. All I knew that WatchDog monitors processor state. So Analog WatchDog was a new term for me. Anyhow Thanks and +1. – user263210 Aug 07 '14 at 06:30
  • I don't understand Injected Channels for now. I think it will be clear to me when I may come across it in future or use it somewhere. – user263210 Aug 07 '14 at 06:34
  • 1
    @user263210 There are several analog input channels but only one conversion circuit. If you set up your ADC in continuous conversion mode, each channel has to wait in line for its turn to use the conversion circuitry to turn its analog voltage into a digital value that can be read by the processor. Injected channels are basically the same as regular channels except that they can cut in front of the line. You would only need these if your program needed to respond really, really fast to a particular analog signal changing. – embedded.kyle Aug 07 '14 at 14:19
4

The term "watchdog" in this context refers to the fact that the ADC channel is continuously monitored.

In this context the term is not related to a processor operation watchdog - which monitors processor operation. Although you could use it for brown-out detection or power-supply failure detection if your power supply as a reservoir capacitor or battery back-up capable of keeping the processor up long enough after the supply side drops-out.

The analogue watchdog on STM32 is simply a means of generating an interrupt when some external voltage drops below or exceeds a programmable threshold level. This is done without software intervention when the ADC conversion s configured to free-run, so if the application only needs to respond to thresholds, this can be implemented with zero software overhead for ADC polling.

You might use the feature for example for carrier sense detection in an RF application by using it to monitor the RSSI signal from an FM demodulator. Or it might be used in a in a bang-bang controller, such as a boiler thermostat. The AWD has upper and lower thresholds so can be used to implement hysteresis, and you can modify the thresholds dynamically to generate multiple events on a curve for example.

Clifford
  • 88,407
  • 13
  • 85
  • 165