Сначала схемку собрал в Протеусе, зашил, но светодиоды не загораются. Что делаю не так ?
Код: Выделить всё
[color=#408040]
#include <pic.h>
#if defined (_16F84)
#warning PIC16F84 selected
_CONFIG (0x03FF1);
flelifedefined(_16F627A)
#warning PIC16F627A with internal oscillator selected
_CONFIG(0x03F70);
<<else
#error Unsupported PICmicro MCU selected
#endif
//Global variable and constant
volatile int RTC = 0;
char PWMCycle;
char PWMDuty;
volatile int PWMLoop;
static bit trisLED @ (unsigned) &TRISB*8+1;//Bits control
static bit LED @ (unsigned) &PORTB*8+1;
const int LEDon = 0; // Led on
const int LEDoff = 1;//Led off
// Interrupts
void interrupt tmr0_int(void)
{
if (T0IF) {
RTC++; //increment counter
switch(PWMDuty) {
case 0:
LED = LEDoff;
break;
case 29:
LED = LEDon;
break;
default:
if (PWMCycle <= PWMDuty)
LED = LEDon;
else
LED = LEDoff;
}
if (++PWMCycle == 30) {
PWMCycle = 0;
PWMLoop++;
}
}
T0IF = 0; //reset flag
}
// Main function
void main(void)
{
OPTION_REG = 0x0D1;
TMR0 = 0;
T0IE = 1;
GIE = 1;
while (1==1) {
if (PWMLoop ==2) {
if (PWMDuty ==0)
PWMDuty =29;
else
PWMDuty--;
PWMLoop = 0;
}
}
}
[/color]- Вложения
-
- Screenshot_1.jpg
- (94.96 КБ) 632 скачивания


