better fitness
parent
907625bffb
commit
61e0390ad2
|
@ -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
|
// Uncalibrated delay, just waits a number of for-loop iterations
|
||||||
void delay(uint16_t iterations)
|
void delay(uint16_t iterations)
|
||||||
{
|
{
|
||||||
uint16_t i;
|
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++) {
|
||||||
__asm nop __endasm;
|
__asm nop __endasm;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#define PPSO_PWM1 3
|
#define PPSO_PWM1 3
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
//OSCCON = 0xf0;
|
OSCCON = 0xf0;
|
||||||
TRISC = 0;
|
TRISC = 0;
|
||||||
//SLRCONC = 0;
|
//SLRCONC = 0;
|
||||||
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 = 0xFF;
|
PWM1DCH = 0x80;
|
||||||
|
PWM1DCL = 0;
|
||||||
PWM1OF = 0;
|
PWM1OF = 0;
|
||||||
PWMLD = 0x07;
|
|
||||||
|
|
||||||
|
|
||||||
PWM1INTE = 0x00; // no interrupts enabled
|
PWM1INTE = 0x00; // no interrupts enabled
|
||||||
PWM1INTF = 0x00; // clear interrupt flag
|
PWM1INTF = 0x00; // clear interrupt flag
|
||||||
PWM1LDCON = 0x80; // load armed
|
PWM1LDCON = 0x80; // load armed
|
||||||
PWM1OFCON = 0x00; // independent run mode
|
PWM1OFCON = 0x00; // independent run mode
|
||||||
PWM1CON = 0x40; // enable, standard PWM mode, active high output
|
PWM1CON = 0x80; // enable, standard PWM mode, active high output
|
||||||
PWMEN = 0x07;
|
|
||||||
|
|
||||||
RC5PPS = PPSO_PWM1;
|
RC5PPS = PPSO_PWM1;
|
||||||
//PWM1OUT = 1;
|
//PWM1OUT = 1;
|
||||||
|
@ -56,12 +57,13 @@ void main(void)
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
//LED_PORT = 1; // LED On
|
//LED_PORT = 1; // LED On
|
||||||
PWM1DCH = 1;
|
PWM1DCH = 0x80;
|
||||||
PWM1LDCON = 0x80; // load armed
|
PWMLD = 1;
|
||||||
delay(300000);
|
delay(300);
|
||||||
//LED_PORT = 0; // LED Off
|
//LED_PORT = 0; // LED Off
|
||||||
PWM1DCH = 0xff;
|
//PWM1DCH = 0xff;
|
||||||
PWM1LDCON = 0x80; // load armed
|
PWM1DCH = 0x10;
|
||||||
delay(300000);
|
PWMLD = 1;
|
||||||
|
delay(300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue