timing_pal not working as expected

cancel
Showing results for 
Search instead for 
Did you mean: 

timing_pal not working as expected

568 Views
chenk
Contributor II

Hello everyone,

Working with the DEVKIT-MPC5748G, I am trying to use the timing_pal module to set a call to a function every fixed time interval. However, the timer doesn't seem to be starting.

timing_pal configuration are pretty much all default except for my callback function (which is of course not called). The module is configured to use the PIT clock.

As troubleshooting, I copy-pasted in the example script that comes with the SDK user manual. Timer init function returns OK status. After starting the timer (cyclic), elapsed time always comes back 0.

main.c is:

/* Write your code here */
CLOCK_DRV_Init(&clockMan1_InitConfig0);

uint64_t resolution;
uint32_t elapsedTime;
/* Initialize TIMING */
TIMING_Init(&timing_pal1_instance, &timing_pal1_InitConfig);
/* Get tick resolution in nanosecond */
TIMING_GetResolution(&timing_pal1_instance, TIMER_RESOLUTION_TYPE_NANOSECOND, &resolution);
/* Start channel counting with period is 1 second */
TIMING_StartChannel(&timing_pal1_instance, TIMER_CHANNEL, (TIMER_PERIOD_NANO / resolution));

/* Get elapsed time in ticks */
elapsedTime = TIMING_GetElapsed(&timing_pal1_instance, TIMER_CHANNEL);
/* Get elapsed time in nanosecond */
elapsedTime = elapsedTime * resolution;

printf("ElapsedTime: %d\n", elapsedTime);

/* De-initialize TIMING */
TIMING_Deinit(&timing_pal1_instance);

Tried different period settings, from a few dozen ticks to the 1-sec equivalent from the sample code. Am I missing something? Am I doing something wrong?

Thanks!

Chen

0 Kudos
6 Replies

295 Views
zhangjk702
Contributor I

hi,chenk

Did you solve the problem? I also encountered the same problem. It seems that the reason is that the callback function is not called. Do you know the solution to the problem? Can you share it?

BR,ZhangJK.

0 Kudos

290 Views
chenk
Contributor II

Hi ZhangJK,

To be honest, I ended up finishing the project with a different MCU so didn't pursue this further.

As I mentioned in the thread, I later had a very similar problem when trying to use a different module which I was able to solve by mapping some internal pins following what was mapped in the relevant demo project (without knowing exactly why they are mapped this way and without having found any clear explanation in the docs).

My only recommendation therefore is that you look through the timing_pal demo projects provided with S32 Design Studio for your MCU and try copying over the pin mapping/routing as they appear in the pin multiplexer settings. Can be tedious but worked for me.

I hope this helps, good luck!

Chen

0 Kudos

483 Views
chenk
Contributor II

Hi again @PetrS,

After facing a seemingly similar problem when trying to use ic_pal for edge detection I went to revisit this issue. Using the example project provided with the SDK everything seems to work as expected but when I use the same code in my own project, the interrupts never get called. However, after copying the PINs configuration over from the SDK project, specifically the ADC(Precision Channel 4-12) and SIUL2(most GPIs), it worked. This is of course besides the LED specific pins.

So my question now is: what are these pins? are they some sort of an internal mapping required for  timer/interrupt operations?

Going through the SDK User Manual I couldn't find any reference to these as prerequisites for neither the timing_pal nor ic_pal modules, am I missing anything?

Embedded programming and this platform in particular are totally new to me, so I am aware my questions are pretty broad and uninformed, but I am willing to put in the time and effort if you only send me in the right direction.

Thanks! Chen.

0 Kudos

470 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi Chen,

most of pins on MCU have multiplexed functionalities, see IO signal table within device Reference manual (excel attached to the RM), so you have to configure the pin for the required function. Within SDK the peripheral configuration may not automatically configure pins. So you should do it by own or at least check it within pin_mux component within its peripheral tabs. 
Maybe below Howto guide can help little bit
https://community.nxp.com/t5/S32-Design-Studio-Knowledge-Base/HOWTO-Create-a-Blinking-LED-Project-MP...  

BR, petr

 

0 Kudos

533 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

testing timing_pal_MPC5748G demo example (from SDK RTM 3.0.0) on the DEVKIT, it  works normally.
Callbacks are called and LEDs toggled with 1sec interval.


Adding below code after PIT/STM start 

/* Get elapsed time in ticks */
elapsedTime = TIMING_GetElapsed(&timing_pal1_instance, PIT_CHANNEL);
/* Get elapsed time in nanosecond */
elapsedTime = elapsedTime * pitResolution;

I got elapsedTime = 5000;

So hard to say in your case, do you have PIT clock enabled in Clock Manager?

BR, Petr

0 Kudos

522 Views
chenk
Contributor II

Hi Petr,

Thank you for taking the time to look at my question. PIT0_CLK is enabled and using the pasted code I couldn't get a reading that's not 0 or get the interrupt to be called. In the meantime, I have moved to a different approach that doesn't require timing_pal, but I will try to get back to it in the next few days to see if maybe the full example code is working. 

Also, sorry for double posting, couldn't find any option to delete a post.

Best regards,

Chen

0 Kudos