fast help plz with my code

Discussion in 'Programmer's Corner' started by ht systems, Aug 18, 2011.

  1. ht systems

    Thread Starter Member

    Aug 2, 2011
    71
    1
    hello there , my code is working in the simulation program but when i put it on the board , its not working , would anyone tell me whats the problem ? im using pic16f630 , 4000000 Mhz and its about three flasher leds
    the code is :
    //Defines:
    /**** Macro Substitutions ****
    portc = LED Port Register
    trisc = LED Data Direction Register
    8 = LED Pin Mask
    1 = LED Active Polarity
    ******************************/
    //LED0: //Macro function declarations
    void FCD_LED0_LEDOn();
    void FCD_LED0_LEDOff();
    //Defines:
    /**** Macro Substitutions ****
    portc = LED Port Register
    trisc = LED Data Direction Register
    4 = LED Pin Mask
    1 = LED Active Polarity
    ******************************/
    //LED1: //Macro function declarations
    void FCD_LED1_LEDOn();
    void FCD_LED1_LEDOff();
    //Defines:
    /**** Macro Substitutions ****
    porta = LED Port Register
    trisa = LED Data Direction Register
    1 = LED Pin Mask
    1 = LED Active Polarity
    ******************************/
    //LED2: //Macro function declarations
    void FCD_LED2_LEDOn();
    void FCD_LED2_LEDOff();
    //LED0: //Macro implementations
    void FCD_LED0_LEDOn()
    {
    trisc = trisc & ~8; //Convert pin to output
    if( 1 ) //Active high polarity
    portc = portc | 8;
    else//Active low polarity
    portc = portc & ~8;
    }
    void FCD_LED0_LEDOff()
    {
    trisc = trisc & ~8; //Convert pin to output
    if( 1 ) //Active high polarity
    portc = portc & ~8;
    else//Active low polarity
    portc = portc | 8;
    }
    //LED1: //Macro implementations
    void FCD_LED1_LEDOn()
    {
    trisc = trisc & ~4; //Convert pin to output
    if( 1 ) //Active high polarity
    portc = portc | 4;
    else//Active low polarity
    portc = portc & ~4;
    }
    void FCD_LED1_LEDOff()
    {
    trisc = trisc & ~4; //Convert pin to output
    if( 1 ) //Active high polarity
    portc = portc & ~4;
    else//Active low polarity
    portc = portc | 4;
    }
    //LED2: //Macro implementations
    void FCD_LED2_LEDOn()
    {
    trisa = trisa & ~1; //Convert pin to output
    if( 1 ) //Active high polarity
    porta = porta | 1;
    else//Active low polarity
    porta = porta & ~1;
    }
    void FCD_LED2_LEDOff()
    {
    trisa = trisa & ~1; //Convert pin to output
    if( 1 ) //Active high polarity
    porta = porta & ~1;
    else//Active low polarity
    porta = porta | 1;
    }
    //Macro implementations
    void main()
    {
    //Initialisation
    cmcon = 0x07;
    //Interrupt initialisation code
    option_reg = 0xC0;
    //Loop
    //Loop: While 1
    while (1)
    {
    //Connection Point
    //Connection Point: [A]: c
    FCC_Main_A:
    ;
    //Call Component Macro
    //Call Component Macro: LED(0)::LEDOn
    FCD_LED0_LEDOn();
    //Delay
    //Delay: 1 s
    delay_s(1);
    //Call Component Macro
    //Call Component Macro: LED(1)::LEDOff
    FCD_LED1_LEDOff();
    //Delay
    //Delay: 1 s
    delay_s(1);
    //Call Component Macro
    //Call Component Macro: LED(2)::LEDOn
    FCD_LED2_LEDOn();
    //Delay
    //Delay: 1 s
    delay_s(1);
    //Call Component Macro
    //Call Component Macro: LED(0)::LEDOff
    ();
     
  2. ht systems

    Thread Starter Member

    Aug 2, 2011
    71
    1
    huh , always no help ?!!!!!!!!
     
  3. stahta01

    Member

    Jun 9, 2011
    133
    21
    I suggest you use code tags; a separate set for each code snippet.
    Put the file name before each code tag.

    I see no config statement/fuse list; this is a common place to make mistakes.

    Note: Most of the people like a schematic or at least a description of the circuit.

    The code you posted seems to be missing the end of the main function.

    Code tags start with [ CODE ] and end with [ /CODE ] ; but without the space before and after the square brackets.

    Edit: Thread on how to use code tags
    http://forum.allaboutcircuits.com/showthread.php?t=36849


    Tim S.
     
    Last edited: Aug 18, 2011
  4. stahta01

    Member

    Jun 9, 2011
    133
    21
    I failed to see where you set the value of SFR ANSEL to permit the analog input to work as digital inputs/outputs.
    Edit: But, after reading the datasheet, I am not sure if the 16F630 has analog inputs. I believe it does not have normal analog inputs that require the use of ANSEL to disable.

    Tim S.
     
    Last edited: Aug 18, 2011
  5. ht systems

    Thread Starter Member

    Aug 2, 2011
    71
    1
    thank you so much
     
  6. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    It seams you are on the correct track now. But as I said in this sticky http://forum.allaboutcircuits.com/showthread.php?t=44852 Learn to use your tools. Any programmer is whortles without debugging knowhow. The link will get you started in simple debugging then it comes to PICs
     
Loading...