Microcontroller RTC &PWM
Microcontroller RTC &PWM
BATCH-08
BATCH MEMBERS:-
CH.AKHIL-221FA05029
T. SAI SANDEEP-221FA05065
DINESH – 221FA05129
GYANDEEP KUMAR – 221FA05230
Introduction To RTC (Real Time Clock)
A Real-Time Clock (RTC) in a microcontroller is a small device that
keeps track of the time and date, even when the system is turned off.
It's like a clock that continues running in the background. The RTC
ensures that the microcontroller always knows the correct time,
which is useful for tasks like setting alarms, recording timestamps, or
scheduling tasks.
Availability of RTC in LPC2148:-
• RTC in LPC2148
1. Purpose:
1. The RTC is used to keep accurate time and date, even when the microcontroller is powered off or
reset.
2. Functionality:
1. Timekeeping: Tracks seconds, minutes, hours, days, months, and years.
2. Alarm: Can set alarms to trigger at specific times or dates.
3. How It Works:
1. The RTC runs on a separate battery or power source so it continues to work even if the main power is
off.
2. It has special registers where you set and read the time and date.
4. Key Features:
1. Clock Registers: Used to store and manage the time and date.
2. Alarm Registers: Set up to generate interrupts or notifications when a specific time is reached.
Purpose of RTC:-
The purpose of a Real-Time Clock (RTC) is to keep track of the current time and date, even when a device is
turned off. It's like having a clock built into a system, so the device always knows the correct time. This is
useful for:
• Setting alarms or reminders
• Recording when something happens (timestamps)
• Scheduling tasks at specific times
BL SetTime ; Set time to 12:30:45 Read RTC time (hours, minutes, seconds)
SetTime
Implementation of the program :-
•Initialize RTC:
This part sets up the Real-Time Clock (RTC) by turning on its clock.
•Set Time:
This sets the RTC to a specific time: 12 hours, 30 minutes, and 45 seconds.
•Read Time:
This reads the current time from the RTC and stores it in registers.
•Infinite Loop:
After doing the above steps, the program enters a loop and keeps running forever.
•Brightness:
•For LEDs, PWM controls brightness. A higher duty cycle (more "on" time) makes the LED brighter, while a
lower duty cycle makes it dimmer.
•For motors, PWM controls speed. More "on" time makes the motor spin faster, while less "on" time makes it
spin slower.
•Control Speed:
Applications using in RTC:-
•PWM on the LPC2148 can be used to control LEDs, motors, or other devices that require varying
power levels.
Advantages of PWM (pulse width modulator):
•Simple to implement
•Efficient and precise power control
•Generates less heat
Disadvantages of PWM:
ENTRY MOV R1, #0x07 ; Set duty cycle to 50% (example value) STR
R1, [R0, #0x08] ; Write to PWM Duty Cycle Register
START
BX LR
BL PWMInit ; Initialize PWM
;Generate PWM
BL SetDutyCycle ; Set initial duty cycle
SignalPWMGenerate
BL PWMGenerate ; Start PWM generation
LDR R0, =0x40000000 ; Base address for PWM register (example address)
B START ; Infinite loop;
Initialize PWM MOV R1, #0x01 ; Enable PWM output (example setting) STR
R1, [R0, #0x0C] ; Write to PWM Enable Register
PWMInit
BX LR
LDR R0, =0x40000000 ; Base address for PWM register (example address)
END