manual genetic algorithm produced 'blinking' led
parent
29721bce3d
commit
907625bffb
|
@ -27,16 +27,41 @@ void delay(uint16_t iterations)
|
||||||
__asm nop __endasm;
|
__asm nop __endasm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#define PPSO_PWM1 3
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
LED_TRIS = 0; // Pin as output
|
//OSCCON = 0xf0;
|
||||||
LED_PORT = 0; // LED off
|
TRISC = 0;
|
||||||
|
//SLRCONC = 0;
|
||||||
|
LED_PORT = 0;
|
||||||
|
PWM1CLKCON = 0x00; // From Fosc w/o prescaler
|
||||||
|
PWM1PRH = PWM1PRL = 0xFF;
|
||||||
|
PWM1PH = 0;
|
||||||
|
PWM1DCH = 0xFF;
|
||||||
|
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;
|
||||||
|
|
||||||
|
RC5PPS = PPSO_PWM1;
|
||||||
|
//PWM1OUT = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
LED_PORT = 1; // LED On
|
//LED_PORT = 1; // LED On
|
||||||
delay(30000); // ~500ms @ 4MHz
|
PWM1DCH = 1;
|
||||||
LED_PORT = 0; // LED Off
|
PWM1LDCON = 0x80; // load armed
|
||||||
delay(30000); // ~500ms @ 4MHz
|
delay(300000);
|
||||||
|
//LED_PORT = 0; // LED Off
|
||||||
|
PWM1DCH = 0xff;
|
||||||
|
PWM1LDCON = 0x80; // load armed
|
||||||
|
delay(300000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue