Bin mittlerweile an dieser Stelle
| 1 | #include <p18f452.h>
 | 
| 2 | #include <pwm.h>
 | 
| 3 | #include <delays.h>
 | 
| 4 | #include <timers.h>
 | 
| 5 | 
 | 
| 6 | #pragma config OSC = HS                 
 | 
| 7 | #pragma config PWRT = ON 
 | 
| 8 | #pragma config WDT = OFF
 | 
| 9 | #pragma config LVP = OFF  
 | 
| 10 | 
 | 
| 11 | 
 | 
| 12 | #pragma code
 | 
| 13 | 
 | 
| 14 | int a;
 | 
| 15 | 
 | 
| 16 | void Delay10mS(int x)
 | 
| 17 |   {
 | 
| 18 |   int i;
 | 
| 19 |     for (i=0; i<x; i++) Delay10KTCYx(12);
 | 
| 20 |   }
 | 
| 21 | 
 | 
| 22 | void main( void )
 | 
| 23 |   {
 | 
| 24 |   TRISB=0x00;                  //PWM am Pin
 | 
| 25 |   OpenTimer2(T2_PS_1_16 & TIMER_INT_OFF);   //Timer2 prescaler 1:16,  interrupts OFF
 | 
| 26 |   OpenPWM1(200);                 //PWMperiod = (200+1)*4*(1/48e6)*16) = 21,3ms --> 4,7kHZ
 | 
| 27 |   
 | 
| 28 |   while(1)                   //dimmen
 | 
| 29 |     {
 | 
| 30 |     for(a=0;a<640; a=a+16)           //Dutycycle 0%  100%
 | 
| 31 |       {
 | 
| 32 |       SetDCPWM1(a);
 | 
| 33 |       Delay10mS(4);
 | 
| 34 |       }
 | 
| 35 |     for(a=0;a<640; a=a+16)           //Dutycycle 100%  0%
 | 
| 36 |       {
 | 
| 37 |       SetDCPWM1(640-a);
 | 
| 38 |       Delay10mS(4);
 | 
| 39 |       }
 | 
| 40 |     }
 | 
| 41 | }
 | 
Es compiliert alles korrekt aber funktionieren 0.0 ?!