Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
7 views

Pseudo Code

code

Uploaded by

aligstanley
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Pseudo Code

code

Uploaded by

aligstanley
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Files

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.

duty_cycle_set(pulse, ADC_value, duty_cycle)


If in pulse = 0, sets the PWM Duty cycle based on the ADC_value.
If in pulse = 1, sets the PWM Duty cycle to add 1 to duty_cycle every
100ms using Delay_ms(100) until it reaches 100 and decreases until it reaches 0.

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.

You might also like