1
\$\begingroup\$

Hello all, I am trying to run simple LED blink program on PIC24FJ64GB004 using PICKit3 programmer, I tried multiple codes but all give same response. When i write a 0 to GPIO it remains at logic 0, but when i write 1 to any GPIO it starts toggling. Same behavior whatever configuration or code i try whatever GPIO i use. Please suggest me where is the issue. Below is one of the codes i've tried but no luck. Please help me out. Thanks all.

#include <p24fxxxx.h>

_CONFIG1( JTAGEN_OFF & //JTAG port is disabled
             GCP_OFF & //GSP Memory Code Protection OFF
             GWRP_OFF & //GCC Flash Write Protection OFF
             FWDTEN_OFF & //Watchdog Timer OFF
             ICS_PGx1) //debug over PGD1 and PGC1

_CONFIG2( FNOSC_FRCPLL & //Internal FRC with PLL
             OSCIOFNC_ON & //RA3 is clk out (fosc/2)
             POSCMOD_NONE & //Primary oscillator disabled
             I2C1SEL_PRI) //Use default SCL1/SDA1 pins



#pragma code

int main(void)
{
   unsigned long i; //a 32 bit variable to use as a timer

   CLKDIVbits.RCDIV0=0; //clock divider to 0
   AD1PCFG = 0xFFFF; // Default all pins to digital
   OSCCONbits.SOSCEN=0; //Disables the secondary oscilator

   TRISAbits.TRISA1 = 0; //sets the Mode LED pin RA1 as output
   LATAbits.LATA1 = 1; //turns LED ON

//////////////////////////////////////////////////////////////////
///FOREVER LOOP///////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
    while(1)
    {

    } 
}

Edit: I am using Microchip PIC24FJ64GB004 PIM, i have added circuit for programming and a crystal below are the schematics attached. Thanks. Schematics

\$\endgroup\$
8
  • \$\begingroup\$ Are you using a proper development board or your own circuit? If the latter please show your schematic. \$\endgroup\$
    – Majenko
    Commented Mar 8, 2015 at 13:19
  • \$\begingroup\$ Thanks for your reply. I am using Microchip PIC24FJ64GB004 PIM, i made a ICSP circuit for programming and added a crystal at pins OSCO(RA3) and OSCI(RA2). Programming with PICKit3 is going fine. Please suggest what might be wrong here. \$\endgroup\$
    – Sidk
    Commented Mar 8, 2015 at 15:51
  • \$\begingroup\$ If that is the entirety of your circuit, then you only have a fraction of the required circuit. Please edit your question and use the schematic editor to draw your circuit exactly as you have it. Include every single component you have in your circuit. Also a photograph of your circuit could be useful. \$\endgroup\$
    – Majenko
    Commented Mar 8, 2015 at 16:07
  • \$\begingroup\$ Please check, I have edited my question with the schematics. \$\endgroup\$
    – Sidk
    Commented Mar 9, 2015 at 6:22
  • 1
    \$\begingroup\$ Nice schematic, but you haven't shown your LED circuit on RA1 (pin 20). Also, in your CONFIG2, try adding IESO_OFF (disabled two-speed startup, you don't need this because you're using the FRC for now). \$\endgroup\$
    – tcrosley
    Commented Mar 9, 2015 at 8:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.