MC1321X Interrupt question.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

MC1321X Interrupt question.

跳至解决方案
1,976 次查看
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.

标签 (1)
0 项奖励
回复
1 解答
940 次查看
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 项奖励
回复
3 回复数
940 次查看
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 项奖励
回复
940 次查看
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 项奖励
回复
941 次查看
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 项奖励
回复