hallo,
hat ein wenig gedauert bis ich erstmal ein pwm signal zusammen bekommen
habe. in dem fall werden ganz simpel leds über die ports PB3 und PB5
gedimmt.
hier der codeschnipsel......
1 | #define zyklus 2000;
|
2 | vorteiler = 20;
|
3 | tast_verhaeltnis = 0;
|
4 |
|
5 | ISR(TIMER0_OVF_vect)
|
6 | {
|
7 | --vorteiler;
|
8 | if(vorteiler == 0)
|
9 | {
|
10 | vorteiler = 20;
|
11 | //hochdimmen
|
12 | tast_verhaeltnis++;
|
13 | for(j=0; j <= tast_verhaeltnis; j++)
|
14 | PORTB &= ~((1 << PB3) | (1 << PB5));
|
15 |
|
16 | for(j=zyklus; j >= tast_verhaeltnis; j--)
|
17 | PORTB |= ((1 << PB3) | (1 << PB5));
|
18 |
|
19 | if(tast_verhaeltnis == zyklus)
|
20 | tast_verhaeltnis = 0;;
|
21 | }
|
22 | }
|
so nun möchte ich mit dem pwm signal leds über ein schieberegister
dimmen (4094).
ich stelle mir das grundsätzlich so vor.......
in der funktion DATA, CLOCK und STROBE sollen die Ports gesetzt
werden....
1 | ISR(TIMER0_OVF_vect)
|
2 | {
|
3 | --vorteiler;
|
4 | DATA();
|
5 | CLOCK();
|
6 | if(vorteiler == 0)
|
7 | {
|
8 | vorteiler = 20;
|
9 | //hochdimmen
|
10 | tast_verhaeltnis++;
|
11 | for(j=0; j <= tast_verhaeltnis; j++)
|
12 | {
|
13 | PORTB &= ~((1 << PB3) | (1 << PB5));
|
14 | STROBE();
|
15 | }
|
16 | for(j=zyklus; j >= tast_verhaeltnis; j--)
|
17 | {
|
18 | PORTB |= ((1 << PB3) | (1 << PB5));
|
19 | STROBE();
|
20 | }
|
21 | if(tast_verhaeltnis == zyklus)
|
22 | tast_verhaeltnis = 0;
|
23 | }
|
24 | }
|
könnte das im grundsatz so richtig sein?
beste grüße
Daniel