LPIT0

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

LPIT0

902 Views
Bhuvana
Contributor I

void Timer_0_Initilization(void)
{
status_t status;

lpit1_ChnConfig0.period =80000;

LPIT_DRV_Init(INST_LPIT_CONFIG_1, &lpit1_InitConfig);

status = LPIT_DRV_InitChannel(INST_LPIT_CONFIG_1, LPIT_CHANNEL, &lpit1_ChnConfig0);
DEV_ASSERT(status == STATUS_SUCCESS);

INT_SYS_InstallHandler(LPIT_Channel_IRQn, &LPIT_ISR, NULL);
}

void Timer_0_Start(void)
{

LPIT_DRV_StartTimerChannels(INST_LPIT_CONFIG_1, (1 << LPIT_CHANNEL));


}
void Timer_1_Initilization(unsigned int period_count)
{
status_t status;

lpit1_ChnConfig0.period =period_count;

LPIT_DRV_Init(INST_LPIT_CONFIG_1, &lpit1_InitConfig);

status = LPIT_DRV_InitChannel(INST_LPIT_CONFIG_1, LPIT_CHANNEL1, &lpit1_ChnConfig1);
DEV_ASSERT(status == STATUS_SUCCESS);

INT_SYS_InstallHandler(LPIT_Channel1_IRQn, &LPIT_ISR1, NULL);
}

void Timer_1_Start()
{

LPIT_DRV_StartTimerChannels(INST_LPIT_CONFIG_1, (1 << LPIT_CHANNEL1));

}
void Timer_2_Initilization(void)
{
status_t status;

LPIT_DRV_Init(INST_LPIT_CONFIG_1, &lpit1_InitConfig);

status = LPIT_DRV_InitChannel(INST_LPIT_CONFIG_1, LPIT_CHANNEL2, &lpit1_ChnConfig2);
DEV_ASSERT(status == STATUS_SUCCESS);

INT_SYS_InstallHandler(LPIT_Channel2_IRQn, &LPIT_ISR2, NULL);
}

void Timer_2_Start(void)
{

LPIT_DRV_StartTimerChannels(INST_LPIT_CONFIG_1, (1 << LPIT_CHANNEL2));


}
void Timer_3_Initilization(void)
{
status_t status;
LPIT_DRV_Init(INST_LPIT_CONFIG_1, &lpit1_InitConfig);


status = LPIT_DRV_InitChannel(INST_LPIT_CONFIG_1, LPIT_CHANNEL3, &lpit1_ChnConfig3);
DEV_ASSERT(status == STATUS_SUCCESS);


INT_SYS_InstallHandler(LPIT_Channel3_IRQn, &LPIT_ISR3, NULL);
}

void Timer_3_Start(void)
{

LPIT_DRV_StartTimerChannels(INST_LPIT_CONFIG_1, (1 << LPIT_CHANNEL3));


}

 

void Timer_Initialization(void)
{
Timer_0_Initilization();
Timer_1_Initilization(16000000);
Timer_2_Initilization();
Timer_3_Initilization();

}

 

int main()

{

Timer_Initialization();

Timer_3_Start();

}

if I do like this below its not working,

int main()

{

Timer_Initialization();

Timer_0_Start();

or

Timer_1_Start();

or

Timer_2_Start();

}

 

 

like this I'm using its working fine but, In Timer_Initilization() function I have initialized Timer_3_Initilization(); last so if i call timer_3_start() its working in this same situation if i call  timer_0 or1,2_nitilization(); its not working... whatever i have initialized last its related start if i call only its  working. why?

I have attached timer configuration also

/* lPIT global configuration */
const lpit_user_config_t lpit1_InitConfig = {
.enableRunInDebug = false,
.enableRunInDoze = false
};

/* Channel configuration 0*/
lpit_user_channel_config_t lpit1_ChnConfig0 = {
.timerMode = LPIT_PERIODIC_COUNTER,
.periodUnits = LPIT_PERIOD_UNITS_COUNTS,
.period = 8000UL,
.triggerSource = LPIT_TRIGGER_SOURCE_INTERNAL,
.triggerSelect = 0U,
.enableReloadOnTrigger = false,
.enableStopOnInterrupt = false,
.enableStartOnTrigger = false,
.chainChannel = false,
.isInterruptEnabled = true
};

/* Channel configuration 1*/
lpit_user_channel_config_t lpit1_ChnConfig1 = {
.timerMode = LPIT_PERIODIC_COUNTER,
.periodUnits = LPIT_PERIOD_UNITS_COUNTS,
.period = 80000UL,
.triggerSource = LPIT_TRIGGER_SOURCE_INTERNAL,
.triggerSelect = 1U,
.enableReloadOnTrigger = false,
.enableStopOnInterrupt = false,
.enableStartOnTrigger = false,
.chainChannel = false,
.isInterruptEnabled = true
};

/* Channel configuration 2*/
lpit_user_channel_config_t lpit1_ChnConfig2 = {
.timerMode = LPIT_PERIODIC_COUNTER,
.periodUnits = LPIT_PERIOD_UNITS_COUNTS,
.period = 6400UL,
.triggerSource = LPIT_TRIGGER_SOURCE_INTERNAL,
.triggerSelect = 2U,
.enableReloadOnTrigger = false,
.enableStopOnInterrupt = false,
.enableStartOnTrigger = false,
.chainChannel = false,
.isInterruptEnabled = true
};

/* Channel configuration 3*/
lpit_user_channel_config_t lpit1_ChnConfig3 = {
.timerMode = LPIT_PERIODIC_COUNTER,
.periodUnits = LPIT_PERIOD_UNITS_COUNTS,
.period = 5600UL,
.triggerSource = LPIT_TRIGGER_SOURCE_INTERNAL,
.triggerSelect = 3U,
.enableReloadOnTrigger = false,
.enableStopOnInterrupt = false,
.enableStartOnTrigger = false,
.chainChannel = false,
.isInterruptEnabled = true
};

everyone is different channel , then it should work na.. otherwise I need to call timer initialize for every timer start how to avoid it?

 

0 Kudos
5 Replies

888 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Bhuvana,

I'm not sure if I understand your question.
Do you mean this works:

int main()
{
Timer_Initialization();
Timer_3_Start();
}

 

But below code not work:

int main()
{
Timer_Initialization();
Timer_0_Start();
or
Timer_1_Start();
or
Timer_2_Start();
}


Please refer to the description of LPIT_StartTimerChannels to check whether the input parameters(mask) of LPIT_DRV_StartTimerChannels match the description.

LPIT_DRV_StartTimerChannels.png

Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

886 Views
Bhuvana
Contributor I

Hi @Robin_Shen 

I have attached my project file in this before while(1) Timer_3_Initilization(); is there so if I call Timer_3_Start(); its working but instead of Timer_3_Start() if I call Timer_0_Start() why its not working. If I call Timer_0_Initilization(); next line Timer_0_Start() that time its working.

so whatever I have Initialize finally that related timer start only working. how to avoid it?

0 Kudos

874 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

You don't need to call LPIT_DRV_Init in each channel initializes function.

LPIT_DRV_Init.png

Please check if each channel is able to run.

0 Kudos

865 Views
Bhuvana
Contributor I

@Robin_Shen Hi sir I have tried after removing LPIT_DRV_INIT() from every initialization now its working fine. Thanks for your guidance

0 Kudos

859 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

You are welcome!
I am glad to hear that it works now.

0 Kudos