100 likes | 281 Views
SGDRS. Software System Design Justin A. King WWU EET Senior project 2013. Hardware Resources. MCU – MSP430G2553 available resources Memory 512B RAM / 16KB ROM 2x 16 bit Timer modules, TA0 and TA1 14 GPIO pins Up to 16MHz bus speed Used resources Memory 6 bytes pf RAM / 1KB ROM
E N D
SGDRS Software System Design Justin A. King WWU EET Senior project 2013
Hardware Resources • MCU – MSP430G2553 available resources • Memory • 512B RAM / 16KB ROM • 2x 16 bit Timer modules, TA0 and TA1 • 14 GPIO pins • Up to 16MHz bus speed • Used resources • Memory • 6 bytes pf RAM / 1KB ROM • Both 16 bit Timer modules, TA0 and TA1 • 3 GPIO pins • 1MHz bus speed (lower power)
Basic overview • The program functions as follows • Initialize the GPIO • Initialize the Timers • Go into LPM3 • When TA0ISR verifies that output should happen, it wakes the CPU up • FOREVER() • IOTask() • Enter LPM3 (until P1ISR wakes the CPU up again)
Kernel • Interrupt driven Kernel • No specific timing requirements • No time slice execution • No task pre-emption • RTC Period • 1 second • Tasks and ISRs • StartTask(), IOTask() • TA0 int, TA1 int, P1 int
StartTask() • Used to start the clocks and set up interrupt pins • Utilizes IO initialize functions from IO module • Sets up Input and Output pins • Sets up a tie down resistor for the PIR sensor so it is not left floating • Utilizes Timer initialize functions from timer module • Sets up the 32.768kHz crystal for RTC timer, TA0 • Sets up parameters for TA1 PWM generation • Execution time: ~1ms • Period: once (at start-up)
IOTask() • Handles mostly output functionality • Checks to see if the spray flag is set by the TA0ISR • If the flag is set, the output pin that drives the FET that is attached to the servo is set • Changes output phase to adjust PWM pulse width for the TA1ISR • Execution time: Up to 2s • Waits for the servo to turn for half a second and then turns it back • Period: Sporadic (occurs when P1ISR wakes the program up from LPM3)
TA0ISR • Functions as the RTC timer for the program • Uses the 32.768kHz crystal • Clock dividers provide a 1s periodic interrupt • On interrupt, it increments a variable SecCount • After 3600 seconds, HourCount is incremented • If HourCount > 24, a SprayFlag is set • Execution time: <3us • Period: Periodic, every 1s
TA1ISR • Used to generate the PWM signal for the servo control • Uses continuous mode timer and adjusts the interrupt period to produce the PWM signals • Produces servo_down and servo_up signals • PWMs with different duty cycles • Depends on the phase that is set by IOTask() • Execution Time: <2us • Period: Sporadic (once a day)
P1ISR • Handles the PIR sensor input functionality • Triggers when a pin on port 1 transitions from logic low to logic high • Checks the spray flag from TA0ISR • If the spray flag is set, it wakes the CPU up from LPM3 • Execution time: ~2us • Period: Sporadic (occurs when PIR is tripped)