cancel
Showing results for 
Search instead for 
Did you mean: 

BlueNRG 2 | INPUT Capture Event is not Work Properly

Aishwarya
Associate III

BlueNRG 2 , MFT (Multi Function Timer) initialized MFT mode 2: dual-input capture mode,

Initialize MFT_Interrupt(MFT1A_IRQn) at HIGH_PRIORITY but program control call interrupt handler at the end of the main function.

void MFT_init()

{

MFT_InitType MFT_structInit;

MFT_structInit.MFT_Mode = MFT_MODE_2;

MFT_structInit.MFT_Prescaler = 0;

MFT_structInit.MFT_Clock1 = MFT_PRESCALED_CLK;

MFT_structInit.MFT_Clock2 = MFT_NO_CLK;

MFT_structInit.MFT_CRA = 0;

MFT_structInit.MFT_CRB = 0;

MFT_Init(MFT1, &MFT_structInit);

MFT_Cmd(MFT1 ,ENABLE);

/* Interrupt Configuration */

MFT_TnEDGES(MFT1, MFT_RISING, MFT_RISING);

MFT1->TNMCTRL_b.TNAEN = ENABLE;

MFT_SetCounter(MFT1, 0xFFFF, 0xFFFF);

MFT_StatusIT(MFT1, MFT_IT_TNA);

MFT_ClearIT(MFT1,MFT1A_IRQn);

}

void NVIC_init()

{

NVIC_InitType NVIC_structInit;

NVIC_structInit.NVIC_IRQChannel = MFT1A_IRQn ;

NVIC_structInit.NVIC_IRQChannelCmd = ENABLE;

NVIC_structInit.NVIC_IRQChannelPreemptionPriority = HIGH_PRIORITY;

NVIC_Init(&NVIC_structInit);

}

int main()

{int main(void)

 {

SystemInit();

GPIO_init();

MFT_init();

NVIC_init();

while (1)

{ SET_BIT(GPIO->OEN, GPIO_Pin_8);

GPIO_ResetBits(GPIO_Pin_8);

GPIO->MFTX_b.MFT1_TIMER_A = 0x08;

touch_State = 1;

MFT1->TNCNT1 = 0xFFFF;

MFT1->TNICTRL_b.TNAIEN = ENABLE;

  CLEAR_BIT(GPIO->OEN, GPIO_Pin_8); //set pin as input

}

}

0 REPLIES 0