cancel
Showing results for 
Search instead for 
Did you mean: 

STR750: TIM0 Using Input Capture for P0.01/TI1 and P1.01/TI2

alexandermueller9
Associate II
Posted on July 12, 2007 at 08:24

STR750: TIM0 Using Input Capture for P0.01/TI1 and P1.01/TI2

5 REPLIES 5
alexandermueller9
Associate II
Posted on June 06, 2007 at 11:16

I would like to count the flash of signals connected to TI1 as well as TI2.

The example attached tries to do that, but in my example it works only with TI2. Looking into 75x_tim.c it seems like either TI1 or TI2 can be used. Is this a hardware requirement or just the way it is implemented in 75x_tim.c (so I would have to write my own version of TIM_Init)?

Thanks a lot in advance

Alexander Mueller

________________

Attachments :

InputCapture.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtL2&d=%2Fa%2F0X0000000aLi%2FzOEI_3QCauQD49z1f8HzEpQi.yVAHPCl5zYxLVBB3pg&asPdf=false
kaouther
Associate II
Posted on June 07, 2007 at 13:06

Hi Alexander,

Both TI1 & TI2 could be used as implemented in 75x_tim.c driver. There is no hardware required; the STR75x software library is developed independently from any hardware and tool chain. on which board are you testing the example? did you tried the TI1 & TI2 separatly?

Regards.

alexandermueller9
Associate II
Posted on June 13, 2007 at 07:33

Quote:

On 07-06-2007 at 16:36, Anonymous wrote:

Hi Alexander,

Both TI1 & TI2 could be used as implemented in 75x_tim.c driver. There is no hardware required; the STR75x software library is developed independently from any hardware and tool chain. on which board are you testing the example? did you tried the TI1 & TI2 separatly?

Regards.

I am working on a Raisonance REva board with STR750 daughter board.

For my tests I have setup the interrupt handler:

void TIM0_IC12_IRQHandler(void)

{

// we toggle the LED everytime TI1 is captured

if(SET == TIM_GetITStatus(TIM0, TIM_FLAG_IC1))

GPIO_WriteBit(GPIO2, GPIO_Pin_13, !GPIO_ReadBit(GPIO2, GPIO_Pin_13));

// we toggle the LED everytime TI2 is captured

if(SET == TIM_GetITStatus(TIM0, TIM_FLAG_IC2))

GPIO_WriteBit(GPIO2, GPIO_Pin_14, !GPIO_ReadBit(GPIO2, GPIO_Pin_14));

TIM_ClearFlag(TIM0, TIM_FLAG_IC1 | TIM_FLAG_IC2);

TIM_ClearITPendingBit(TIM0, TIM_IT_IC1 | TIM_IT_IC2);

}

To test the behaviour I connected GPIO2.10 with the channel

TI1 and then TI2 (having the other channel connected to GND).

GPIO2.10 is toggled in ''TB_IRQHandler'' every 500ms. Should be

enough to use as an input for TI1 and/or TI2.

First Test: use input channel 1

For this I have set tim.TIM_Channel = TIM_Channel_1 (main.c line 94).

Result when connecting with TI1:

The interrupt handler is executed as expected, but the flags for both channels get set (though not at the same time).

Result when connecting with TI2:

no interrupt handler as expected

Second Test: use input channel 2

Result when connecting with TI2:

Interrupt handler is executed and the LED for TI2 is toggled (TI1 not).

Works as expected

Result when connecting with TI1:

no interrupt handler as expected

Third Test: use input channel ALL

The results are the same as with the second test.

So signal at TI1 doesnt trigger!

In my understanding of the souce code either TI1 OR TI2 can be used:

(code snipptet from 75x_tim.c / ICAP_ModuleConfig):

static void ICAP_ModuleConfig(TIM_TypeDef* TIMx, TIM_InitTypeDef* TIM_InitStruct)

{

if(TIM_InitStruct->TIM_Mode == TIM_Mode_PWMI)

:

}

else

{

if(TIM_InitStruct->TIM_Channel == TIM_Channel_1)

{

:

}

else

Thanks a lot for your help

Alexander Mueller

PS: 75x_tim.c has version number 07/17/2006 : V1.0

kaouther
Associate II
Posted on June 18, 2007 at 08:49

Hello,

At the first, the input capture module is used to latch the value of the counter after a transition detected by the corresponding ICx input. To get the external signal period we need two consecutive captures and the period is calculated by subtracting these two values. In this case, the counter is not reset when an edge is detected on ICx pins.

To avoid this method, the ICAP_ModuleConfig() function uses the STR75x Synchronization feature which synchronize the counter with the external signal. That means when an edge is detected, the counter is reseted and the period of the external signal is automatically given by the value on the ICRX registers.

This needs to configure the SCR register:

- the Slave Mode Selection:SMS;,

- the Trigger Selection: TS

- the Slave Mode Enable: SME

At this case with the trigger selection 'TS' configuration, only one Input capture could be used; IC1 or IC2.

The the ICAP_ModuleConfig()function facilitates to get automatically the value from the ICRx register and use the new Timer feature on STR75x.

However, if you need to use both the IC1 and IC2, you can still use the TIM init, and you have just to reset the SME, SMS and TS bits. Then, you need to calculate the period of the external signal after two consecutive captures.

Thanks.

alexandermueller9
Associate II
Posted on July 12, 2007 at 08:24

Thanks a lot for your reply.

To get an interrupt on TI1 and TI2 I added:

TIM_Init(TIM0, &tim);

TIM0->SCR = (1 << 14);

TIM0->IMCR =

(0 << 0) | // IC1S=TI1

(0 << 1) | // IC2S=TI2

(1 << 2) | // IC1 Enable

(1 << 4); // IC2 Enable

Using this everything worked like a charm.

Alexander Mueller