Timer capture interrupt issue on LPC1549

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Timer capture interrupt issue on LPC1549

2,425件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cbd8992 on Wed May 27 03:31:19 MST 2015
Hi,

I am using the timer capture function on the LPC1549 for reading out the data of a digital KMA215 angle sensor. For calculating the value I have to detect falling edges of the output signal and with the time difference between each edge I am able to reconstruct the message.

The code for calculating the message works perfectly fine on the LPC4330 but on the LPC1549 the SCT0 just doesn't detect some falling edges. Because of this, nearly 45% of reading attempts fail. The minimum time between two falling edges is 3us and I am running the SCT with 12MHz.

I attached a picture of an oscilloscope capture where you can see the problem. The blue line is the output signal from the sensor and the red line shows the status of the pin, that I let toggle in the SCT interrupt handler for test purposes.

This is the code I used to initialize the SCT:
void SENT_init(void) {
/* reset flags */
timeout_flag = false;

Chip_GPIO_SetPinDIRInput(LPC_GPIO, 1, 6);

Chip_SCT_Init(LPC_SCT0);
Chip_SCT_Config(LPC_SCT0, (SCT_CONFIG_32BIT_COUNTER)); //use a unified counter
LPC_SCT0->COUNT_U = 0;//set counter to 0

LPC_SCT0->EVEN = 0x01;//enable event 0

LPC_SCT0->REGMODE |= (1 << 0);//register 0 is a capture register
LPC_SCT0->CAPCTRL[0].U |= (1 << 0);//event 0 causes capture 0

LPC_SCT0->EVENT[0].STATE = 0xFFFFFFFF;//happens in every state

LPC_SCT0->EVENT[0].CTRL = (0 << 0) |        //use capture register 0
(0x2 << 10) |//detect falling edges
(0x2 << 12) |//use I/O condition only
(1 << 14) |//STATEV is loaded
(0 << 15);//new state: 0


Chip_INMUX_SelectSCT0Src(0, SCT0_INMUX_PIO1_6);

Chip_SCT_EnableEventInt(LPC_SCT0, SCT_EVT_0); /* Enable an Interrupt on the Capture Event */

NVIC_EnableIRQ(SCT0_IRQn);


timerFreq = Chip_Clock_GetSysTickClockRate();

NVIC_SetPriority(SENT_TIMER_NVIC_NAME, SENT_TIMER_INTERRUPT_PRIORITY); // interrupt priority

Chip_SCT_ClearControl(LPC_SCT0, SCT_CTRL_HALT_L | SCT_CTRL_HALT_H);//start counter
}


And this is the interrupt handler:
void SENT_TIMER_TIMER_IRQ_HANDLER(void) 
{



if (LPC_SCT0->EVFLAG & 0x01) {
LPC_SCT0->EVFLAG = 0x01;//Clear interrupt flag

/* read timer counter */
newCapValue = LPC_SCT0->CAP[0].U;
sentDelay = newCapValue - oldCapValue;
oldCapValue = newCapValue;
}
}


For the CAN controller initialization I have following line, if I delete it the failure rate increases to about 98%
/* Use main oscilator for rates above 100Kh */
Chip_Clock_SetMainClockSource(SYSCTL_MAINCLKSRCA_SYSOSC);




Does anyone have any idea why the SCT misses some falling edges?


Thanks,

Pascal
ラベル(1)
6 返答(返信)

1,797件の閲覧回数
athmesh_n
Contributor IV

Hi,

How can you find the no of revolutions using capture register?

0 件の賞賛
返信

1,797件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Thu Dec 17 09:23:22 MST 2015
Just found this post, and my SCT capture that was missing some edges is now fixed.

I was just wondering WHY it needs to be synchronised: my input signal is <625Hz and the SCT is clocked from the PLL at 45.16MHz, so each input pulse is more than 72000 clocks long, so how can the SCT possible miss it?
0 件の賞賛
返信

1,797件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Thu May 28 03:32:34 MST 2015

Quote: cbd8992
I now tried setting INSYNC and it works perfectly fine!



Good to hear that 

BTW: It's not necessary to set your SCT capture to (GPIO) input...

Chip_GPIO_SetPinDIRInput(LPC_GPIO, 1, 6);

1,797件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cbd8992 on Thu May 28 02:52:05 MST 2015
I now tried setting INSYNC and it works perfectly fine! :D

The calculation comes from a colleague, who implemented the calculation on another board without the SCT and I tried to get it to work like this before I try something new. I have never worked with the SCT before and had a few problems getting it to work in the first place. Now that it works I will try to make it faster using the Limit register.

The other interrupts didn't have any effect on my SCT interrupts, I already tried running only the SCT0 code.

Thank you very much for your help!
0 件の賞賛
返信

1,797件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LabRat on Wed May 27 13:58:06 MST 2015

Quote: cbd8992
Does anyone have any idea why the SCT misses some falling edges?



Without seeing your code it's difficult to guess  :((

Probably your interrupt management is causing this problems  :)

As already suggested it could be useful to run the SCT0 part of your program without other interrupts...

SCT is able to generate 3µs interrupts, at least if there are no other interrupts serviced...
0 件の賞賛
返信

1,797件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Wed May 27 05:18:12 MST 2015
Did you try to set INSYNC already?

Did you try to use SCT0 without other interrupts (CAN)?

BTW: Why are you using a slow delay calculation (sentDelay = newCapValue - oldCapValue) instead of using Limit register?
0 件の賞賛
返信