# test my code

#### ht systems

Joined Aug 2, 2011
71
hello , this is my new code for a flasher led , will u see if there is a problem in it ?
//************************************************************************************
//**
//** File name: C:\Program Files\Flowcode V4\???? ????\Flowcode1.c
//** Generated by: Flowcode v4.2.3.58
//** Date: Friday, August 19, 2011 04:31:52
//** Licence: Professional
//** Registered to: 2A1RRG
//**
//**
//** http://www.matrixmultimedia.com
//************************************************************************************

#define MX_PIC
//Defines for microcontroller
#define P16F630
#define MX_EE
#define MX_EE_TYPE1
#define MX_EE_SIZE 128
//Functions
#define MX_CLK_SPEED 19660800
#ifdef _BOOSTC
#include <system.h>
#endif
#ifdef
HI_TECH_C
#include <pic.h>
#endif
//Configuration data
#ifdef _BOOSTC
#pragma DATA 0x2007, 0x3fef
#endif
#ifdef
HI_TECH_C
__CONFIG(0x3fef);
#endif
//Internal functions
#include "C:\Program Files\Flowcode V4\FCD\internals.h"
//Macro function declarations

//Variable declarations

//Defines:
/**** Macro Substitutions ****
portc = LED Port Register
trisc = LED Data Direction Register
1 = LED Active Polarity
******************************/

//LED0: //Macro function declarations
void FCD_LED0_LEDOn();
void FCD_LED0_LEDOff();

//LED0: //Macro implementations

void FCD_LED0_LEDOn()
{

trisc = trisc & ~2;
//Convert pin to output
if( 1 ) //Active high polarity
portc = portc | 2;
else //Active low polarity
portc = portc & ~2;
}
void FCD_LED0_LEDOff()
{

trisc = trisc & ~2;
//Convert pin to output
if( 1 ) //Active high polarity
portc = portc & ~2;
else //Active low polarity
portc = portc | 2;
}
//Macro implementations
void main()
{

//Initialisation
cmcon = 0x07;

//Interrupt initialisation code
option_reg = 0xC0;

//Loop
//Loop: While 1
while (1)
{
//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(0)::LEDOff
FCD_LED0_LEDOff();

//Delay
//Delay: 1 s
delay_s(1);

}

mainendloop:
goto mainendloop;
}
void MX_INTERRUPT_MACRO(void)
{
}

#### guitarguy12387

Joined Apr 10, 2008
359
Have you tested it yourself?

P.S.

Last edited by a moderator:

#### DumboFixer

Joined Feb 10, 2009
217
Is this actually your code or is it the code produced by the Flowcode program from the flowchart that you (?) wrote ?

Yes I can see some problems, mainly with code that cannot be executed.

#### ht systems

Joined Aug 2, 2011
71

#### DumboFixer

Joined Feb 10, 2009
217
As was asked, have you tested the code (run it through the Flowcode simulator) ?

I think a problem lies with the way decision boxes have been used in that you have a constant and not a variable.

The problem is not with the code but with your flowchart - the code matches, I imagine, the flowchart. Have a closer look at the decision boxes.

#### ht systems

Joined Aug 2, 2011
71
yes i tested but it didnt work so i thought that the code have a problem but u opened my eyes about the variable , i tested it on flowcode and it worked but in the real its not working .
i hope that you would tell me why its working on flowcode and not working in the real .
thank you all so much for helping me

#### DumboFixer

Joined Feb 10, 2009
217
If you look at the functions for turning the LED on/off you'll see a piece of code similar to this:
Rich (BB code):
if( 1 ) //Active high polarity
portc = portc | 2;
else//Active low polarity
portc = portc & ~2;

Can you see the error in this bit of code ?

hint: what causes the else part to be executed ?

#### ht systems

Joined Aug 2, 2011
71
So I have to delete the simulation's code or to change it. When I tested in real nothing turned on ( leds ) and I tested the A and it was zero and V was 5 as I put it in the generator.

#### DumboFixer

Joined Feb 10, 2009
217
If you include your flowchart file I may be able to have a look at it and try and point you in the right direction (but you are going to have to do the hard work yourself).

#### ht systems

Joined Aug 2, 2011
71
here is my flowcode , i hope no problems would happen when you open it

#### Attachments

• 11.6 KB Views: 15

#### DumboFixer

Joined Feb 10, 2009
217
I need the .fcf file - a screen dump doesn't tell me about variables etc.

#### ht systems

Joined Aug 2, 2011
71
i put all of what you need

#### Attachments

• 36.7 KB Views: 13

#### DumboFixer

Joined Feb 10, 2009
217
I will have a detailed look at the code when I get a chance. Can you post circuit schematic you ar eusing as it could be a circuit problem.

#### ht systems

Joined Aug 2, 2011
71
Ok I will wait for your answer and building it on a test board so I don't have a schematic circuit

#### ht systems

Joined Aug 2, 2011
71
Mr Dumbofixer , im still waiting for your replay sir .
thank you

#### stahta01

Joined Jun 9, 2011
133
Ok I will wait for your answer and building it on a test board so I don't have a schematic circuit
This is a mistake; create the schematic diagram then build the circuit.

Tim S.

Last edited: