Unit 4
Unit 4
Unit 4
MICROCONTROLLER FUNDAMENTALS
FOR BASIC PROGRAMMING
I/O pin Multiplexing
Switch̲ State Input ̲ Pin̲ State Switch̲ State Input ̲ Pin̲ State
Direction Register :
GPIO Direction (GPIODIR) register as an input or output.
• When the data direction bit=0 input
• When the data direction bit =1 Output
Data Register :
GPIODATA register is the data register
Watchdog Timer
• A watchdog timer is a hardware timing device that triggers a system reset if the main
program, due to some fault condition, such as a hang, neglects to regularly service the
watchdog.
• System restart or reset
• Interval Timer
– Generate interrupts
Watchdog Timer:
• A watchdog timer counter enters a counter lapse or timeout after it reaches certain
count.
• Normal operation: the program running the system continuously resets the watchdog
timer.
• When the system enters an infinite loop or stops responding, it fails to reset the
watchdog timer.
• The TM4C123GH6PM microcontroller has two Watchdog Timer modules:
• Watchdog Timer 0 - Clocked by the system clock
• Watchdog Timer 1 - Clocked by the PIOSC
Need for Low Power Microcontroller
It is imperative for an embedded design to be low on its power consumption. Most
embedded systems and devices run on battery. Power demands are increasing rapidly, but
battery capacity cannot keep up with its pace. Therefore, a microcontroller which inherently
consumes very less power is always encouraging. However, embedded systems engineers
usually need to optimize between power and performance. Power and performance are
inversely proportional to each other.
Hibernation Module:
• Hibernation Module manages to remove and restore power
• reduces system power consumption.
• When the processor and peripherals are idle, power can be completely removed if the
Hibernation module is only the one powered.
The Hibernation module of TM4C provides two mechanisms for power control:
1. Uses internal switches to control power to the Cortex-M4F.
2. controls the power to the microcontroller with a control signal (HIB) that signals an external
voltage regulator to turn on or off.
Fig:
Interrupts
Interrupts
Types of interrupts
1. Software driven interrupts (SWI) :
• SWIs are generated from within a currently executing program.
• A SWI will call a subroutine that allows a program to access certain lower level service.
• Provides seconds, minutes, hours, day of week, day of month, month, and year in real-time clock with
calendar function
• Interrupt capability
• The pwmA and pwmB signals produced by each PWM generator are passed to the dead-
band generator.
• If disabled, the PWM signals simply pass through to the pwmA' and pwmB' signals
unmodified.
• If enabled, the pwmB signal is lost and two PWM signals are generated based on the
pwmA signal.
• The first output PWM signal, pwmA' is the pwmA signal with the rising edge delayed by a
programmable amount.
• The second output PWM signal, pwmB', is the inversion of the pwmA signal with a
programmable delay added between the falling edge of the pwmA signal and the rising
edge of the pwmB' signal.
• The resulting signals are a pair of active high signals where one is always high, except for
a programmable amount of time at transitions where both are low.
• These signals are therefore suitable for driving a half-H bridge, with the dead-band
delays preventing shoot-through current from damaging the power electronics.
Quadrature Encoder Interface (QEI):