Problem on Build a Project: Build Errror: Undefined Reference to "tenthSecond","oneSecond"....

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
JoLo_284096
Level 4
Level 4
First like received

Dear All:

   

Just starting to say that I am new on PSOC Creator and maybe you can tell me what is wrong with the code below. When I try to build the SW that I attache (timing.h, timing.c and main.c)  I get the error above. Anyhelp will be appreciated. Thanks in advance to all.

   

Regards,Joaquin

   

-----timing.h code:-----

   

#include <project.h>
#include <device.h>

/******************************************
*       Global Variables
******************************************/

extern uint8 milliSecond;
extern uint8 tenthSeconds;
extern uint8 oneSecond;
extern uint8 tenSeconds;

/******************************************
*   Function Prototypes
******************************************/

/******************************************
*   Function Name: InitTiming()
*******************************************
void InitTiming(void);
//[] END OF FILE

   

 

   

---Code for timing.c:---

   

#include <device.h>
#include <timing.h>
#include "stdio.h"
#include "stdint.h"

/******************************************
*   Global Variables
******************************************/
//Event flags for each of the time periods
uint8 tenthSeconds= 0U;
uint8 oneSecond= 0U;
uint8 tenSeconds= 0u;

/******************************************
*       Private Functions
******************************************/
/******************************************
*Function Name: TimeISR()
******************************************
*******************************************/
static CY_ISR(TimerIsr)
{
   
// Counters for the longer periods
static uint8  tenthSecondsCount= 0U;
static uint16 oneSecondCount= 0U;
static uint16 tenSecondsCount= 0U;
   
(void)PWM_Timer_STATUS;
//milliSecond = 1U; // Always set the millisecond global event flag

//Check if a tenth second has passed
if (tenthSecondsCount > 99U)
{    tenthSeconds = 1U;//tenthSecond global event flag
    tenthSecondsCount=0;
}
else
    tenthSecondsCount++;

//Check if a second has passed
if (oneSecondCount > 999U)
{
    oneSecond = 1U; //oneSecond global event flag
    oneSecondCount=0;
}
else
    oneSecondCount++;

//Check if a tenseconds has passed
if (tenSecondsCount > 9999U)
{
    tenSeconds = 1U; //tenSeconds global event flag
    tenSecondsCount=0;
}
else
    tenSecondsCount++;

} //End of TimeIsr();

/******************************************
*       Global Functions
******************************************/

/******************************************
*Function Name: InitTiming()
******************************************/
void InitTiming(void)
{
    isr_PWM_Start();
    isr_PWM_SetVector(TimerIsr);
} // End of InitTiming()


/* [] END OF FILE */

   

---Code for main C---

   

#include <project.h>
#include <device.h>
#include <stdio.h>
#include "timing.h"
#include "UART.h"

#define LCD_NUM_COLUMNS (16u)

uint8 datos[3]= {0x65, 0x66, 0x67};

void main()
{  
    char8 ch;       /* Data received from the Serial port */
    uint8 count = 0u;
    uint8 pos = 0u;

    CyGlobalIntEnable; /* Enable all interrupts by the processor. */
    InitTiming();       // Interrupt
    PWM_Timer_Start();  //Source of interrupt

    LCD_Char_1_Start();
    UART_OXI_Start();
    CyDelay(30); // just to be sure the UART is up and running
    isr_1_Start();      /* Initializing the ISR */
    UART_OXI_ClearRxBuffer();//Clear RXbuffer

    while(1)
    {
        /* Check the UART status */
        ch = UART_OXI_GetChar();

        /* If byte received */
        if(ch > 0)
        {
            count++;       
            /* If the count value reaches the count 16 start from first location */
            if(count % LCD_NUM_COLUMNS == 0u)
            {
                pos = 0u; /* resets the count value */
                /* Display will be cleared when reached count value 16 */
                LCD_Char_1_WriteControl(LCD_Char_1_CLEAR_DISPLAY);
            }

            LCD_Char_1_Position(0u, pos++);
            LCD_Char_1_PutChar(ch);         /* Print the received character */

            LCD_Char_1_Position(1u, 0u);
            LCD_Char_1_PrintInt8(count);    /* Prints the count in the LCD */
                        
            UART_OXI_SendData(ch);/* Sending the data to Hyperterminal */
         
        }
       
    }
}


/* [] END OF FILE */

0 Likes
14 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

You have declared as external tenthSecond & oneSecond, but no where do I see

   

their initialization declaration ? Thats what the compiler is complaining about.

   

Are these defined in in another file that is not "#include"-ed ?

   

 

   

Regards, Dana.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

tenthSeconds, oneSecond and tenSeconds are initialized at the top of timing.c. This should be fine.

   

Maybe you can upload your project? (File / Create workspace bundle) That way we can compile for ourself...

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked
        The error is quite obvious, you defined your variables as "tenthSeconds" (with a trailling "s", plural) but the reference is to "tenthSecond" with no "s" at the end.   
   
Bob   
0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Yes but compiler complaining about oneSecond as well. Its references all typed

   

properly.

   

 

   

Maybe compiler overreach on scan, reporting an error triggered by another ?

   

 

   

Regards, Dana.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

In the code I can not see a reference to 'tenthSecond', there is only one in a comment. So it should compile, except when there is something we don't know about...

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked
        ... but when I look at the error provided in the thread's heder...   
   
Bob   
0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

So something doesn't fit together - the source code doesn't match the error message. That's why we need the source...

0 Likes
JoLo_284096
Level 4
Level 4
First like received

Hello all and thanks for your support.

   

I have deleted all the "s" and still have the problem. I have done a bundle as you have proposed and please, find attached.  Really  I appreciate any comment.

   

Thanks in advance,

   

Joaquin.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Change the externals in timing.h to -

   

 

   

   

extern uint8 milliSecond;

   

   

extern uint8 tenthSecond;

   

extern uint8 oneSecond;

   

extern uint8 tenSecond;

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

When building the UART_HOST project, I see the same problem as dana (conflicting declarations of the variables), but this is not the one you described.

   

The real error happens on the UART_TFT project. It is because you reference the variables there in main.c, but don't declare them anywhere (timing.cfrom the first project is not part of this project...).

   

Remember, each of your four projects is separate. So you need to define your variables in each of them, and they will be different ones...

0 Likes
JoLo_284096
Level 4
Level 4
First like received

Hello:
Effectively I have deleted the UART_TFT_TOUCHSCREEN  project from the workspace and it works. I had this project in the workspace for reference but it was disturbing more than helping.

   

Thank you all for your support.

   

Joaquin.

   


 

0 Likes
Anonymous
Not applicable

Hello,

   

I want a program which is combination of some programs, I created a program by two ways of combining first is to create header & source file & then add them in one main file & second is by calling function. I created but i'm getting some errors in both of the program.

   

errors in first program are -undefined reference to `UART_DEB_PutCRLF'

   

                                           undefined reference to `UART_DEB_PutString'

   

Errors in second program are- expected identifier or '(' before 'typedef'

   

                                                unknown type name '__int8_t'

   

The errors in second program are in generated source.

   

I'm attaching both of my programs here, Please give me suggestions.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Cannot load the first archive, files are missing or paths are wrong.

   

Your errors in second file are quite too much, I would suggest you to start anew combining 2 projects and then adding the 3rd...

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Ok, Got it.

   

Thank You.

0 Likes