I'm getting an error that says my defined constant is not a function. It's not supposed to be a function.

This is the error...

Tick.c:389:35: error: called object '200000000ul' is not a function

It points to...

#define TICKS_PER_SECOND    ((GetPeripheralClock()+128ull)/256ull)

GetPeripheralClock has the error. It comes from...

    #define GetSystemClock (200000000UL)
    #define GetInstructionClock (GetSystemClock/2)
    #define GetPeripheralClock (GetSystemClock)

Where is it deciding it is a function?

Probably the parentheses on line 1. Remove them and see if it compiles.

#define GetSystemClock 200000000UL

Same with line 3

#define GetPeripheralClock GetSystemClock

Edited 2 Years Ago by Ancient Dragon

Rats! Didn't help. Looked like it might work though.
The whole function with the error is...

    DWORD TickConvertToMilliseconds(DWORD dwTickValue)

    Converts a Tick value or difference to milliseconds.

    This function converts a Tick value or difference to milliseconds.  For
    example, TickConvertToMilliseconds(32768) returns 1000 when a 32.768kHz
    clock with no prescaler drives the Tick module interrupt.


    dwTickValue - Value to convert to milliseconds

    Input value expressed in milliseconds.

    This function performs division on DWORDs, which is slow.  Avoid using
    it unless you absolutely must (such as displaying data to a user).  For
    timeout comparisons, compare the current value to a multiple or fraction
    of TICK_SECOND, which will be calculated only once at compile time.
DWORD TickConvertToMilliseconds(DWORD dwTickValue)
        return (dwTickValue+(TICKS_PER_SECOND/2000ul))/((DWORD)(TICKS_PER_SECOND/1000ul));

#define TICKS_PER_SECOND ((GetPeripheralClock()+128ull)/256ull

The compiler sees GetPeripheralClock() as a function call -- remove the ()

#define TICKS_PER_SECOND ((GetPeripheralClock+128ull)/256ull

Edited 2 Years Ago by Ancient Dragon

Oh Great! I just got the meaning of the remarks so I did a search and TickConvertToMilliseconds isn't used anywhere so I'm just going to comment this section out.
I still wonder where it decided to change it to a function though.

Edited 2 Years Ago by kent.johnstone_1

This article has been dead for over six months. Start a new discussion instead.