diff --git a/src/blink_led.c b/src/blink_led.c index d110ec0..01f2f36 100644 --- a/src/blink_led.c +++ b/src/blink_led.c @@ -21,33 +21,34 @@ __code uint16_t __at (_CONFIG1) __configword = _FOSC_INTOSC & _CLKOUTEN_OFF & _W // Uncalibrated delay, just waits a number of for-loop iterations void delay(uint16_t iterations) { - uint16_t i; + uint16_t i, j; for (i = 0; i < iterations; i++) { // Prevent this loop from being optimized away. + for (j = 0; j < 1000; j++) { __asm nop __endasm; + } } } #define PPSO_PWM1 3 void main(void) { - //OSCCON = 0xf0; + OSCCON = 0xf0; TRISC = 0; //SLRCONC = 0; LED_PORT = 0; PWM1CLKCON = 0x00; // From Fosc w/o prescaler PWM1PRH = PWM1PRL = 0xFF; PWM1PH = 0; - PWM1DCH = 0xFF; + PWM1DCH = 0x80; + PWM1DCL = 0; PWM1OF = 0; - PWMLD = 0x07; PWM1INTE = 0x00; // no interrupts enabled PWM1INTF = 0x00; // clear interrupt flag PWM1LDCON = 0x80; // load armed PWM1OFCON = 0x00; // independent run mode - PWM1CON = 0x40; // enable, standard PWM mode, active high output - PWMEN = 0x07; + PWM1CON = 0x80; // enable, standard PWM mode, active high output RC5PPS = PPSO_PWM1; //PWM1OUT = 1; @@ -56,12 +57,13 @@ void main(void) while (1) { //LED_PORT = 1; // LED On - PWM1DCH = 1; - PWM1LDCON = 0x80; // load armed - delay(300000); + PWM1DCH = 0x80; + PWMLD = 1; + delay(300); //LED_PORT = 0; // LED Off - PWM1DCH = 0xff; - PWM1LDCON = 0x80; // load armed - delay(300000); + //PWM1DCH = 0xff; + PWM1DCH = 0x10; + PWMLD = 1; + delay(300); } }