if you cant tell im totally new to C. i can find my way through C+, but this is all screwy so im going to have to disassemble existing code (with help from whoever wants to) to figure it out. and im using a silicon labs 8051fx20 IDE
im working with timers and interrupts to make a traffic light simulation. i want to alter some existing code to suit my needs.
ive changed the intial timing of the interrupt from 5 times a second:
Code:
Timer3_Init (SYSCLK / 12 / 10);
to
Code:
Timer3_Init (SYSCLK / 12 / 12);
in order to hopefully get 4 times a second (if 10 = 5 times a sec, then 50 = 1 sec, 50/4 = 12.5).
i am hoping i can use a delay or sleep function and just put it how many ms i want it to wait(to bypass all the machine cycle and timer overflow stuff), but i dont know if i can with the IDE.
i need to use the LED on the board (P1.6) as the green light, and use a series of while loops to switch the ports on and off.
ie: main street will use P1.0, P1.1, and P1.6 for the red, yellow and green respectively. side street uses P1.2, P1.3, and P1.4.
[psuedo]
Code:
while (delay <= 25000)
turn P1.6 on
turn P1.2 on
while (delay >= 25001)
turn P1.6 off
turn P1.1 on
while (delay >= 29001)
turn P1.0 on
turn P1.1 off
turn P1.2 off
turn P1.4 on
while (delay >= 54001)
turn P1.4 off
turn P1.3 on
if (delay > 58000)
clear delay
restart delay
[/pseudo]
if its possible to do what i want, how could i restart the delay and create an infinite loop?
if i cant use delay, then im stuck with machine timers and overflows...ugh
any insight is much appreciated