Skip to main content
Reviewed the answer again.
Source Link
user211748
user211748

I solvedwas able to solve the problem with the help of @rohat-kılıç.

It seemsappears that some of my LED's were brokendamaged. I set the

The external clock frequency is set to high speed (HS). This is the

The updated code can be found here.

#include <pic.h>

#ifndef _XTAL_FREQ
// The clock frequency is 16 Mhz
#define _XTAL_FREQ 16000000
#endif

__CONFIG (FOSC_HS & WDTE_OFF & LVP_OFF & CPD_OFF & CP_OFF);

int main()
{
    TRISB = 0; // PORTB is output

    while(1)
    {
        /* RB5 PORTB6 is on */
        PORTB = 0x20;  // b0010 0000

        /* wait for a second */
        __delay_ms(1000);

        /* all leds on PORTB is off */
        PORTB = 0;

        /* wait for a second */
        __delay_ms(1000);
    }
}

I solved the problem with the help of @rohat-kılıç.

It seems that some of my LED's were broken. I set the external clock frequency to high speed (HS). This is the updated code.

#include <pic.h>

#ifndef _XTAL_FREQ
// The clock frequency is 16 Mhz
#define _XTAL_FREQ 16000000
#endif

__CONFIG (FOSC_HS & WDTE_OFF & LVP_OFF & CPD_OFF & CP_OFF);

int main()
{
    TRISB = 0; // PORTB is output

    while(1)
    {
        /* RB5 PORTB6 is on */
        PORTB = 0x20;  // b0010 0000

        /* wait for a second */
        __delay_ms(1000);

        /* all leds on PORTB is off */
        PORTB = 0;

        /* wait for a second */
        __delay_ms(1000);
    }
}

I was able to solve the problem.

It appears that some of my LED's were damaged.

The external clock frequency is set to high speed (HS).

The updated code can be found here.

#include <pic.h>

#ifndef _XTAL_FREQ
// The clock frequency is 16 Mhz
#define _XTAL_FREQ 16000000
#endif

__CONFIG (FOSC_HS & WDTE_OFF & LVP_OFF & CPD_OFF & CP_OFF);

int main()
{
    TRISB = 0; // PORTB is output

    while(1)
    {
        /* RB5 PORTB6 is on */
        PORTB = 0x20;  // b0010 0000

        /* wait for a second */
        __delay_ms(1000);

        /* all leds on PORTB is off */
        PORTB = 0;

        /* wait for a second */
        __delay_ms(1000);
    }
}
Updated code for blinky
Source Link
user211748
user211748

I solved the problem with the help of @rohat-kılıç.

It seems that some of my LED's were broken. I set the external clock frequency to high speed (HS). This is the updated code.

#include <pic.h>

#ifndef _XTAL_FREQ
// SetThe clock frequency is 16 Mhz
#define _XTAL_FREQ 16000000
#endif

__CONFIG (FOSC_HS & WDTE_OFF & LVP_OFF & CPD_OFF & CP_OFF);

int main()
{
    TRISB = 0; // PORTB is output

    while(1)
    {
        /* all leds onRB5 PORTBPORTB6 is on */
        PORTB = 0xff;0x20;  // b0010 0000

        /* wait for a second */
        __delay_ms(1000);

        /* all leds on PORTB is off */
        PORTB = 0;

        /* wait for a second */
        __delay_ms(1000);
    }
}

I solved the problem with the help of @rohat-kılıç.

It seems that some of my LED's were broken. I set the external clock frequency to high speed (HS). This is the updated code.

#include <pic.h>

#ifndef _XTAL_FREQ
// Set clock frequency 16 Mhz
#define _XTAL_FREQ 16000000
#endif

__CONFIG (FOSC_HS & WDTE_OFF & LVP_OFF & CPD_OFF & CP_OFF);

int main()
{
    TRISB = 0; // PORTB is output

    while(1)
    {
        /* all leds on PORTB is on */
        PORTB = 0xff;

        /* wait for a second */
        __delay_ms(1000);

        /* all leds on PORTB is off */
        PORTB = 0;

        /* wait for a second */
        __delay_ms(1000);
    }
}

I solved the problem with the help of @rohat-kılıç.

It seems that some of my LED's were broken. I set the external clock frequency to high speed (HS). This is the updated code.

#include <pic.h>

#ifndef _XTAL_FREQ
// The clock frequency is 16 Mhz
#define _XTAL_FREQ 16000000
#endif

__CONFIG (FOSC_HS & WDTE_OFF & LVP_OFF & CPD_OFF & CP_OFF);

int main()
{
    TRISB = 0; // PORTB is output

    while(1)
    {
        /* RB5 PORTB6 is on */
        PORTB = 0x20;  // b0010 0000

        /* wait for a second */
        __delay_ms(1000);

        /* all leds on PORTB is off */
        PORTB = 0;

        /* wait for a second */
        __delay_ms(1000);
    }
}
Source Link
user211748
user211748

I solved the problem with the help of @rohat-kılıç.

It seems that some of my LED's were broken. I set the external clock frequency to high speed (HS). This is the updated code.

#include <pic.h>

#ifndef _XTAL_FREQ
// Set clock frequency 16 Mhz
#define _XTAL_FREQ 16000000
#endif

__CONFIG (FOSC_HS & WDTE_OFF & LVP_OFF & CPD_OFF & CP_OFF);

int main()
{
    TRISB = 0; // PORTB is output

    while(1)
    {
        /* all leds on PORTB is on */
        PORTB = 0xff;

        /* wait for a second */
        __delay_ms(1000);

        /* all leds on PORTB is off */
        PORTB = 0;

        /* wait for a second */
        __delay_ms(1000);
    }
}