PIT TIMER IS NOT WORKING with ADC and RTC || MPC5748G || S32DS

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

PIT TIMER IS NOT WORKING with ADC and RTC || MPC5748G || S32DS

1,017 Views
priya_p
Contributor IV

I am trying to configure PIT timer to take ADC and RTC reading in every 5 second. But it is never coming to PIT handler to turn on flag as one, so that it will enter into loop and takes the reading. I can't understand where it is going wrong.

For configuring PIT, what I provided is listed below.

/*initialize clocks*/

CLOCK_DRV_Init(&clockMan1_InitConfig0);

/* Install PIT ch0 handler*/
INT_SYS_InstallHandler(PIT_Ch0_IRQn, &pitCh0Handler, NULL);

/* Initialize the timer module*/
PIT_DRV_Init(INST_PIT1, &pit1_InitConfig);

/* Initialize the timer channel 0*/
PIT_DRV_InitChannel(INST_PIT1, &pit1_ChnConfig1);

/* Start the counter for channel 0*/
PIT_DRV_StartChannel(INST_PIT1, 0U);

 

priya_p_0-1619689767961.png

Note: I am using MPC5748G DevKit.

I am attaching the project and the screenshot of pit component Inspector. Please help me.

0 Kudos
3 Replies

1,006 Views
petervlna
NXP TechSupport
NXP TechSupport

Hello,

I am trying to configure PIT timer to take ADC and RTC reading in every 5 second. But it is never coming to PIT handler to turn on flag as one, so that it will enter into loop and takes the reading. I can't understand where it is going wrong.

Could you please specify what you want to achieve closer?

Do you want to trigger PIT interrupt handler? Which will then serve ADC or RTC?

Best regards,

Peter

 

0 Kudos

1,000 Views
priya_p
Contributor IV

I need PIT to run the program and take the readings in every 5 seconds. 

 

PIT HANDLER

{

//TURN FLAG =1

}

 

int main()

{

while(1)

{

IF(FLAG==1)  // in every 5 second it goes to interrupt handler and make flag as one.

{

//TAKE ADC READING

//GET TIMESTAMP FROM RTC

// WRITE IT TO EEPROM

//make flag=0

}

}

}

 

But it is not at all going to PIT handler to turn the flag as one. I don't know where I did wrong.

0 Kudos

981 Views
petervlna
NXP TechSupport
NXP TechSupport

Hello,

Lets make sure we both understand what you want to achieve.

I need PIT to run the program and take the readings in every 5 seconds.

PIT is a simple timer and it cant run any program. I guess you are referring to PIT interrupt (IVOR4) where the routine should be executed by core.

But it is not at all going to PIT handler to turn the flag as one. I don't know where I did wrong.

First make sure your PIT is configured to trigger interrupt. You will see TIF flag set on PIT timeout.

petervlna_0-1620025813341.png

Once this is setup, you need to setup INTC controller to process the interrupt from PIT.

Set priority:

// assing required peripheral priorities and core which will process interrupt (in this case there is only one core)
INTC_0.PSR[226].R = 0x8001; // PIT0

Enable external interrupts in core  by MSR [EE].

Once all is set you will get into IVOR4 once PIT timeout occurs.

You further need to set up interrupt vector table and interrupt handler.

Please have a look at example SW I have posted where it is demonstrated:

https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/Example-MPC5744P-PIT-triggering-interrupts/ta-p/...

Best regards,

Peter

 

 

0 Kudos