Pseudo Code
Pseudo Code
Functions
Description
Timer.c
count_down(run_timer)
This function will initialize Timer1 and count up to 1 second. A logic
will use the variable pause_timer to enable or disable the interrupt. If run_timer
= 1, run, if run_timer = 0, disable. interruptEN = run_timer;
delay_ms(delay)
This function will initialize Timer2 and trigger ISR when it reaches
delay. It will be used to generate the PWM.
Timer1 ISR
The ISR toggles the LED_on and decrements the global variable
timer_set_value by 1. If timer_set_value reaches 0 it sets a flag
count_down_finish.
Timer2 ISR
The ISR sets the flag back to 0.
UART.c
display_time(timer_set_value, display_mode)
This function will display the time in the format m:ss based on the
current value of timer_set_value (which is in seconds). If display_mode = 0, show
only time, if display_mode = 1, show ADC reading and LED intensity setting as well.
get_time_input(enable_input)
If enable_input = 1, this function will get three user character inputs
(only numbers) in the format m:ss and when it gets all three numbers it sets
timer_set_value to the time in seconds, sets enable_input to 0 and returns.
set_display_mode(display_mode)
If user presses 'i' toggle display_mode.
LED.c
initialize()
read_ADC(ADC_value)
Reads the value at the potentiometer and stores it in global variable
ADC_value.
LED_control(duty_cycle, LED_on)
If LED_on = 1, use delay_ms(duty_cycle*period/100) and delay_ms(period
- duty_cycle*period/100) to toggle the LED. If LED_on = 0, LED is off.