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
();
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
();