Timersmanagers.c timers are not incrementing.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Timersmanagers.c timers are not incrementing.

1,466 Views
dave_harmonjr
Contributor III

Hello,

I am having an issue with interval timers using the timersmanager on the KW41z on a custom board. I started with the bluetooth uart freertos project. In short the timers never go off and call the callback functions. I stepped through numerous places in the program and all the allocate timer functions and things like that return true or successful. I set a breakpoint where it starts the timer and then set a 10ms delay ( the interval timer is 50ms). I then called the function to return the remaining time and no matter the delay it returns 50ms so it appears like it is not being incremented at all and thus never getting called.

I am looking for some help into resolving this or pointers on where to look in the code for possible missing initialization issues etc. I checked the PDF for the connectivity library could not find anything relevant to my knowledge.

I have a 32MHz crystal that is copied exactly from the dev board and I am using an RTC chip to provide an external 32khz clock to the external input pin. I verified the operation of the 32khz signal with a scope. I made sure to have the clocks configuration tool set to choose an external clock for the 32khz and updated the code so I believe that should be working?

I can provide anything that may be useful to help.

Thanks in advance,

Dave

0 Kudos
11 Replies

1,257 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi David, I hope you're doing well!

 

When creating a timer using the TimerManager service in the Connectivity Framework, first it has to be initialized using the TMR_Init() function. This will create a task for the timer and initialize relevant hardware. After this is called, the timer must be started with the TMR_StartTimer function.

 

Timer activity can be checked with the TMR_IsTimerActive function, could you please let me know if this function also returns TRUE?

 

Could you please let me know if the SDK example was modified in any way before testing it?

 

If a fresh Wireless UART example project is imported into your workspace and loaded directly to the custom board, do the timers work?

 

Best regards,

Sebastian

1,257 Views
dave_harmonjr
Contributor III

I am working on trying to get the default project to run on the custom board. It has a couple of changes needed to the DCDC code for it to work with the buck mode, i believe its default in bypass mode. Also the pins they use for a switch in it will not working with the custom board as they are in use for some other ics.

There are several modifications done to it.

  • DCDC set to buck and to output to 3.3V to the Digital io supplies
  • keyboard switches changed to different pins
  • serialmanager changed from using uart to spi

Thats the only system level changes I can think of that are in it. Everything else is just functions that use the spi port basically.

The TMR_IsTimerActive function returns false. I tried this and it still returned false each time:

TMR_MakeTMRThreadReady(); //Tried this both on and off
TMR_StartIntervalTimer(mKeyScanTimerID, gKeyScanInterval_c, (pfTmrCallBack_t)KeyScan, (void*)((uint32_t)mKeyScanTimerID));

OSA_TimeDelay(10);
bool_t testBool = TMR_IsTimerActive(mKeyScanTimerID);
TMR_EnableTimer(mKeyScanTimerID);
OSA_TimeDelay(10);
testBool = TMR_IsTimerActive(mKeyScanTimerID);
TMR_GetRemainingTime(mKeyScanTimerID);
TMR_MakeTMRThreadReady();

I also noted that when I open the threads window I can see the TMR Task is still in the eventwait function and doesn't leave it as far as I can see stepping through each line of that.

0 Kudos

1,257 Views
dave_harmonjr
Contributor III

I did some more debugging and found that the status of the timer in question returns as "ready" but not active. So it fails the masking check in the function to determine if its active. It seems like the Timer task is just not receiving event updates? And not a failure of the timer from incrementing in general?

0 Kudos

1,257 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi David,

 

Could you please try incrementing the amount of available timers for your application by increasing the gTmrApplicationTimers_c definition? This could be why the timer is not being started successfully.

 

More information about these macros can be found in the Connectivity Framework Reference Manual pdf, included with the SDK in the following path:

 

<…\SDK_SDK_2.2.1_FRDM-KW41Z\docs\wireless\Common\Connectivity Framework Reference Manual.pdf>

 

Please let me know if you still have issues.

 

Best regards,

Sebastian

0 Kudos

1,257 Views
dave_harmonjr
Contributor III

I resolved the breakpoint issue by using a J-Link Programmer so now I can breakpoint in other threads.

0 Kudos

1,257 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi David,

 

It's good to know you got your breakpoints working!

 

Are you still having issues with the timer?

 Is the Timer Allocation function returning an expected value?

 

Best regards,

Sebastian

0 Kudos

1,257 Views
dave_harmonjr
Contributor III

After getting the thread breakpoints to work by switching to a JLink from a Multilink I was able to determine there was a syntax issue in the switch statement made by myself to handle the keyswitches which caused it to always go to the default statement and break out without doing anything. The breakpoints not working on the multilink misled me into thinking many things were not working. Another thing to note is I think I may have been pressing resume debugging and resume all debugging interchangeably causing some of the threads to stay suspended by the debugger. Only using the resume all and getting the breakpoints to work allowed me to  see the switch statement not working as intended.

0 Kudos

1,257 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi David,

 

It's good to hear that you fixed the issue!

 

Please let me know if you need any more information or have any further issues.

 

Best regards,

Sebastian

0 Kudos

1,257 Views
dave_harmonjr
Contributor III

I went to put a breakpoint in the Timer Task and get this error in the console:

PE-ERROR: ERROR: Expected 4 threads but only found 3
PE-ERROR: ERROR: Could not find thread-id 20002CC8

That is the id for the Timer Task (I breakpointed where the task gets started to check as well). If I change the breakpoint to a different task I get the same error as well with a different id, and it appears breakpoints are not working in any other task except the main one.

Perhaps once I nail this down it will be easier to figure out what is going on with the timers/events.

0 Kudos

1,257 Views
dave_harmonjr
Contributor III

Unfortunately still having the same issue. It almost seems like the event set and event wait functions are not working at all. I am trying to dig more into that. If you can think of any other areas to look at let me know. Thanks so much for the help so far.

0 Kudos

1,257 Views
dave_harmonjr
Contributor III

Attached is the problem project in question.

Thanks a ton!

0 Kudos