No output on pins in pic24f

I can't get my pic24f04kl100 to turn on an LED at all. The below code is as simple as possible and it still doesn't turn on the LED on pin 6.

Code
#include <xc.h>

#define LED LATBbits.LATB4
#define LEDans ANSBbits.ANSB4
#define LEDtris TRISBbits.TRISB4

/* Setting up configuration bits */
_FOSCSEL(FNOSC_FRCPLL & IESO_OFF);  // FRC w/PLL and int./ext. switch disabled
_FOSC(POSCMD_XT & FCKSM_CSECMD);    // Pri. OSC XT mode and clk. switch on, fail-safe off
_FWDT(FWDTEN_OFF);                  // Watchdog timer off

void initialise();
void delay(int i);

void main() {                      // Main program loop
    initialise();                  // Intialise PIC
    while (1) {                    // Infinite loop
        LED = 1;                   // Set LED high
        LED = 0;                   // Set LED low
    }
}

void initialise() {                // Configures the PIC
    OSCCONbits.NOSC = 0b111;        // Fast RC Oscillator with Postscaler and PLL module
    delay(100);
    CLKDIVbits.RCDIV = 0b000;       // Set clock div 1:1
    delay(100);
    LEDans = 0;
    delay(100);
    LEDtris = 0;                    // Make LED an output
    delay(100);
    LED = 0;                        // Set LED low
}

void delay(int i) {
    while(i--);
}
PICkit 3 Output
*****************************************************

Connecting to MPLAB PICkit 3...
Firmware Suite Version.....01.27.04
Firmware type..............dsPIC33F/24F/24H

Target detected
Device ID Revision = 0

The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x3ff
configuration memory

Programming...
Programming/Verify complete

Answers


By default B4 pin is analog. Configure it as digital by clearing the ANSB register, bit4

NOTE: Although clearing the bit DID NOT fix the problem. Moving to another pin (with less features) did. So I (fossum) made the assumption that this was at least on some level the correct answer.


The LED is blinking, but it's blinking very fast, try to put some delay between LED turn on and LED turn off.

Try this:

void main() { // Main program loop initialise(); // Intialise PIC while (1) { // Infinite loop LED = 1; // Set LED high delay(50000); //wait LED on time LED = 0; // Set LED low delay(50000); //wait LED off time } }


Need Your Help

c++/Qt: How to get a reference to database in the MainWindow class?

c++ database qt sqlite qt-creator

In Qt-creator, I created SQLite database in a class called databaseManager, as follow:

IIS server on Windows Server 2012 not opening a website

asp.net windows server iis-8 sql-server-2014-express

I have Windows Server 2012 and SQL Express 2014 running on it. I set up IIS on it and uploaded my website as well as the database.