0
\$\begingroup\$

I'm new to harmony framework, and am trying to find how i can count timer iterations, so i'm doing a simple test.

I configured the timer like this:

enter image description here

Now i want to know if this is the correct way:

    uint32_t teste;
    case APP_STATE_SERVICE_TASKS:
    {
        while(1){
            teste = DRV_TMR0_CounterValueGet;
            printf("tmr val %d \r\n",teste);
            DRV_TMR0_CounterValueSet(0);
        }

        break;
    }

It happens that when i go see the print it's always the number 1660931680 doesn't make much sense to me, the timer is 16-bit so the maximum number should be somewhere near 65500.

What is wrong here?

\$\endgroup\$
0
\$\begingroup\$

You are probably getting the memory address of the DRV_TMR0_CounterValueGet function rather than the return value because you didn't call the function. You must call the function with () i.e.

teste = DRV_TMR0_CounterValueGet();

(not teste = DRV_TMR0_CounterValueGet;)

\$\endgroup\$
  • \$\begingroup\$ Hi @pm101 thanks it is always 0 now even after taking away DRV_TMR0_CounterValueSet(0);, do you know whats missing? i did DRV_TMR0_Start(); on APP_STATE_INIT \$\endgroup\$ – Nmaster88 Jun 13 at 7:46
  • \$\begingroup\$ Ok i found what was wrong, i had timer period equal to one. I need to understand it now. \$\endgroup\$ – Nmaster88 Jun 13 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.