MC1321X Interrupt question.

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

MC1321X Interrupt question.

Jump to solution
1,952 Views
Warren_Weigel
Contributor II

I using the MC13213NCB and I cannot seem to get interupts to work. I am trying to use TPM1 Channel 0 to generate an interupt to increment a counter and use that counter to time a time slice. I have added the vector to the vector table and when I look at the memory when a breakpoint is reached the correct initiated values are loaded into register x35. It seems no matter what I do it will not signal the interupt, so my code just waits until the counter reaches a value, but it is always 0.

 

When I startup the microcontoller I initialize the delay timer and the interrupts.When I run the program it stops at the while loop in the attached code. When I reference ENABLE_INT(), it is defined as "asm cli".

 

Is there some sort of initialization I am forgetting.

 

Any help would be greatly appreciated.

Labels (1)
0 Kudos
Reply
1 Solution
916 Views
Warren_Weigel
Contributor II

I was able to get it working. The OCDlyInit() function was setting the right clockA:clockB value, but MCUInit() was setting it to x00. I switched the order of the two and it runs.

 

 

View solution in original post

0 Kudos
Reply
3 Replies
916 Views
bigmac
Specialist III

Hello Warren, and welcome to the forum.

 

You have not shown the code that initialises the TPM module operation. This might possibly be within the MCUinit() function.  Your problem could be within this code.  Additionally, what method did you use to implement your ISR function within the vector table?  What is the definition of the ISR macro?

 

The ENABLE_INT() macro provides the global enabling of all the individual interrupts that have been enabled within initialisation process for each module.

 

While not associated with your current problem, a couple of further comments about your ISR code -

  1. The expression TPM1C0SC_CH0F = 0;  that controls a specific bit, actually provides read-modify-write code.  So the separate expression to read the flag is unnecessary.
  2. To increment the channel register, I would tend to use the expression TPM1C0V += E_PER_MS;  This will avoid cumulative timing errors due to any latency in executing the ISR code.

 

Regards,

Mac

0 Kudos
Reply
916 Views
Warren_Weigel
Contributor II

bigmac, I appreciate your help. I understand what you said about the TPM1C0SC_CHOF, I don't know why it was there. I have also changed the code to use TPM1C0V += E_PER_MS.

 

The MCUInit() function is found in mcu_hw_config.c from Freescale. I have provided a copy of the MCUInit() function. I have also provided a copy of the vector table in the attachment. I don't know what is meant by the ISR macro.

 

I have also provided a copy of OCDlyInit which initializes the TPM1.

 

I still don't know why it will not work.

 

Thanks again for helping.

0 Kudos
Reply
917 Views
Warren_Weigel
Contributor II

I was able to get it working. The OCDlyInit() function was setting the right clockA:clockB value, but MCUInit() was setting it to x00. I switched the order of the two and it runs.

 

 

0 Kudos
Reply