Please, where is the error in code (with 16F628)?
OUT1 - LED1 OUT2 - LED2
Flashing only LED1 (OUT1). The counter is not working (bad integer?). HW is okay... My code:
#include "PIC16F628.h"
#include "pic.h"
#pragma config FOSC = INTOSCIO
#define OUT1 RB1
#define OUT2 RB2
#define _XTAL_FREQ 4000000
//******************************************
void main()
{
int x;
TRISB1=0;
TRISB2=0;
OUT1=0;
OUT2=0;
if (x < 10)
{
x++;
OUT1=1;
__delay_ms(1000);
OUT1=0;
__delay_ms(1000);
}
else if (x >= 10)
{
x = 0;
OUT2=1;
__delay_ms(1000);
OUT2=0;
__delay_ms(1000);
}
}
And in this code blink only OUT2:
#include "PIC16F628.h"
#include "pic.h"
#include <stdio.h>
#include <stdlib.h>
#include "stdint.h"
#pragma config FOSC = INTOSCIO
#define OUT1 RB1
#define OUT2 RB2
#define _XTAL_FREQ 4000000
uint8_t x = 10;
//************************
void main()
{
TRISB1=0;
TRISB2=0;
OUT1=0;
OUT2=0;
while(1)
{
if (x < 10)
{
x++;
OUT1=1;
__delay_ms(1000);
OUT1=0;
__delay_ms(1000);
}
else if (x >= 10)
{
x = 0;
OUT2=1;
__delay_ms(1000);
OUT2=0;
__delay_ms(1000);
}
}
}
Also in the debugger variable x is not change. Compiler is XC8.