Interrupt cannot be triggered when PS1 is input captured in MC912ZVL128

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

Interrupt cannot be triggered when PS1 is input captured in MC912ZVL128

1,226 次查看
AsaZJP
Contributor III

Hi Dear:

     Interrupt cannot be triggered when PS1 is input captured in MC912ZVL128. 

Do you have any special uses for ps1 pins?Or does PS1 not support input capture?Here is my code.Thanks .

/* define */
#define TIM0TC_ARR ((volatile word *) &TIM0TC0)


/* init handle */
/* Routing IOC_2 to ps0*/
MODRR2 = 0x04;
/* Routing IOC_3 to ps1*/
MODRR2 |= 0x08;
/* TIM0 IC3 routing */
MODRR4 &= ~0x03;

/* Timer System Control Register 1 */
TIM0TSCR1 = 0x80;
/* Timer System Control Register 2 */
TIM0TSCR2 = 0x05; /* 1 Mhz*/
/* Timer Count Register */
TIM0TCNT = (uint16) 0x0000;
/* Timer Toggle On Overflow Register 1 */
TIM0TTOV = (uint8) 0x00;

/* Timer Input Capture/Output Compare Select */
TIM0TIOS &= ~((uint8)(0x1<<3));
TIM0TCTL4 |= (uint8)(0x03 << 6);


/* Interrupt handle */
/* Clear timer Interrupt Flag */
TIM0TFLG1 = (uint8)(0x1<<3);
/* Get timer counter */
u16Data = *(TIM0TC_ARR + 3);

Another very strange phenomenon is that when debugging, PS1 as input capture, can normally execute the input capture interrupt, but when exiting debug, PS1 as input capture, cannot trigger the capture interrupt.

Best regards,

Asa .Zhai

0 项奖励
回复
2 回复数

1,201 次查看
AsaZJP
Contributor III

Hi Ladislav:

      I had test it , it's ok ;  Thank you very much ;

Best regards,

Asa .Zhai

0 项奖励
回复

1,214 次查看
lama
NXP TechSupport
NXP TechSupport

Hi,

MODRR2 can be:

Read: Anytime
Write: Once in normal, anytime in special mode

Your code write it twice.... so in the debug mode it is working. In normal...NO.

It is not related to specific bits only but to entire byte. The operation works over the entire register even it is bit instruction (read-modify-write process is performed always)

So use MODRR2 = 0B00001100; /* Routing IOC_3 to ps1, IOC_2 to ps0*/

Be careful when you use such type of registers.

// TIM0 input capture channel 3 is connected to pin selected by MODRR2[T0C3RR]
// so TIM0 channel3 is routed to PS1
MODRR4 &= ~0x03; // OK

TIM0TSCR1 = 0x80; // ...I suggest
TIM0TSCR1 = 0B10100000; // enable timer and stop timer counting in freeze(debug/step....I mean when the code stops in degugging process) mode.


TIM0TSCR2 = 0x05; /* 1 Mhz*/ // it looks like 32*1MHz=32MHz


TIM0TCNT = (uint16) 0x0000; // Write: Has no meaning or effect in the normal mode; // only writable in special modes .
The period of the first count after a write to the TCNT registers may be a different size because the write
is not synchronized with the prescaler clock.


* Timer Input Capture/Output Compare Select */
TIM0TIOS &= ~((uint8)(0x1<<3)); // timer0 ch3 output compare
TIM0TCTL4 |= (uint8)(0x03 << 6); // OK


Moreover, I do not see enabling all I-bit maskable interrupts.
The code
Enableinterrupts;
or you can use
asm CLI;

I do not see you enabled interrupt ... 15.3.2.8 Timer Interrupt Enable Register (TIE)

I do not see interrupt routine.

If you want of me to deeper investigation I have to see entire project which is oriented only to the issue to see everything.

I have attached two examples for input capture.

Best regards,
Ladislav

 

0 项奖励
回复