master
Yorick van Pelt 2019-01-09 01:46:48 +01:00
parent 61e0390ad2
commit 45068a2816
Firmato da: yorick
ID Chiave GPG: D8D3CC6D951384DE
1 ha cambiato i file con 20 aggiunte e 15 eliminazioni

Vedi File

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