How to install a timer interrupt

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

How to install a timer interrupt

Jump to solution
896 Views
wendersonolivei
Contributor IV

Hi All,

 

I was using timer interrupt with PEx, but when I tried to install an isr manually it doesn't work.

That's my code:

 

void tpm1_interr(void *user_isr_ptr) {      Bit2_NegVal(); //Output led      TPM1_SC |= 0x10000000; //Clears TOF flag by writing a logical '1' }   void Task1_task(uint32_t task_init_data) //Main task {      _int_install_isr(LDD_ivIndex_INT_TPM1, tpm1_interr, NULL);      TPM1_SC = 0xF;      TPM1_CNT = 0x2;      TPM1_MOD = 0x0000ffff;      TPM1_C0SC = 0x00000050;      TPM1_C0V = 0x0000ffff;      for(;;)      {           _time_delay_ticks(300);      } }

 

When I try to play the program the debugger goes at this unhandled exception isr:

 

PE_ISR(Cpu_Interrupt) {        /* This code can be changed using the CPU component property "Build Options / Unhandled int code" */        PE_DEBUGHALT(); }

 

Why this is happening? My isr_install is wrong?

Thanks,

Original Attachment has been moved to: full-code-(isr-install).zip

Tags (3)
0 Kudos
1 Solution
568 Views
danielchen
NXP TechSupport
NXP TechSupport

HI

Sorry I forgot to add opensda debug support in this project.  now I attached the updated version.


Have a great day,
Daniel

View solution in original post

0 Kudos
5 Replies
568 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi

I attached an example to install interrupt handler, for your reference. You can set break point in Task1_task, at the last line, you can get the result, isr_ptr->TICK_COUNT is 200.

This task installs a new ISR to replace the timer ISR.,   It then waits for some time, finally printing out the    number of times the ISR ran.


Have a great day,
Daniel

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

568 Views
wendersonolivei
Contributor IV

Hi Daniel,

I tried to make a code, like as your example, but it stills doesn't works.

I attached my code, can you give a little look on this?

Thanks,

0 Kudos
569 Views
danielchen
NXP TechSupport
NXP TechSupport

HI

Sorry I forgot to add opensda debug support in this project.  now I attached the updated version.


Have a great day,
Daniel

0 Kudos
568 Views
wendersonolivei
Contributor IV

Now i can run this on my FRDM, it's working fine!

Thanks a lot, have a nice day.

Wenderson

0 Kudos
568 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi

I think the vector number (in your code is LDD_ivIndex_INT_TPM1) is not right