breathing led
parent
61e0390ad2
commit
45068a2816
|
@ -22,11 +22,12 @@ __code uint16_t __at (_CONFIG1) __configword = _FOSC_INTOSC & _CLKOUTEN_OFF & _W
|
||||||
void delay(uint16_t iterations)
|
void delay(uint16_t iterations)
|
||||||
{
|
{
|
||||||
uint16_t i, j;
|
uint16_t i, j;
|
||||||
|
|
||||||
for (i = 0; i < iterations; i++) {
|
for (i = 0; i < iterations; i++) {
|
||||||
// Prevent this loop from being optimized away.
|
// Prevent this loop from being optimized away.
|
||||||
for (j = 0; j < 1000; j++) {
|
//for (j = 0; j < 12; j++) {
|
||||||
__asm nop __endasm;
|
__asm nop __endasm;
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#define PPSO_PWM1 3
|
#define PPSO_PWM1 3
|
||||||
|
@ -35,12 +36,12 @@ void main(void)
|
||||||
OSCCON = 0xf0;
|
OSCCON = 0xf0;
|
||||||
TRISC = 0;
|
TRISC = 0;
|
||||||
//SLRCONC = 0;
|
//SLRCONC = 0;
|
||||||
|
OPTION_REGbits.PSA = 1;
|
||||||
LED_PORT = 0;
|
LED_PORT = 0;
|
||||||
PWM1CLKCON = 0x00; // From Fosc w/o prescaler
|
PWM1CLKCON = 0x00; // From Fosc w/o prescaler
|
||||||
PWM1PRH = PWM1PRL = 0xFF;
|
PWM1PRH = PWM1PRL = 0xFF;
|
||||||
PWM1PH = 0;
|
PWM1PH = 0;
|
||||||
PWM1DCH = 0x80;
|
PWM1DCH = PWM1DCL = 0;
|
||||||
PWM1DCL = 0;
|
|
||||||
PWM1OF = 0;
|
PWM1OF = 0;
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,15 +56,19 @@ void main(void)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while (1) {
|
while(1) {
|
||||||
//LED_PORT = 1; // LED On
|
delay(1);
|
||||||
PWM1DCH = 0x80;
|
while (PWM1DCL < 0xFF || PWM1DCH < 0xFE) {
|
||||||
PWMLD = 1;
|
if (PWM1DCL == 0xFF) PWM1DCH++;
|
||||||
delay(300);
|
PWM1DCL++;
|
||||||
//LED_PORT = 0; // LED Off
|
PWMLD = 1;
|
||||||
//PWM1DCH = 0xff;
|
delay(1);
|
||||||
PWM1DCH = 0x10;
|
}
|
||||||
PWMLD = 1;
|
while (PWM1DCL > 0 || PWM1DCH > 0) {
|
||||||
delay(300);
|
if (PWM1DCL == 0) PWM1DCH--;
|
||||||
}
|
PWM1DCL--;
|
||||||
|
PWMLD = 1;
|
||||||
|
delay(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue