Dear Sir,
i am SCTimer Input capture implemented in LPC54628 EVK Board
following code developed using config tool ( Pins & Peripherals Init ) but interrupt does not occurs why?
Please suggestion where is mistake in my code, please help me sir.
// Pin_mux.c
void BOARD_InitBootPins(void)
{
SCTimer_InitPins();
}
/* clang-format off */
//* FUNCTION ************************************************************************************************************
*
* Function Name : SCTimer_InitPins
* Description : Configures pin routing and optionally pin electrical features.
*
* END ****************************************************************************************************************/
/* Function assigned for the Cortex-M4F */
void SCTimer_InitPins(void)
{
/* Enables the clock for the input muxes. 0 = Disable; 1 = Enable.: 0x01u */
CLOCK_EnableClock(kCLOCK_InputMux);
/* Enables the clock for the IOCON block. 0 = Disable; 1 = Enable.: 0x01u */
CLOCK_EnableClock(kCLOCK_Iocon);
INPUTMUX->SCT0_INMUX[0] = ((INPUTMUX->SCT0_INMUX[0] &
/* Mask bits to zero which are setting */
(~(INPUTMUX_SCT0_INMUX_INP_N_MASK)))
/* Input number to SCT0 inputs 0 to 6.
* : 0x00u. */
| INPUTMUX_SCT0_INMUX_INP_N(0x00u));
const uint32_t SCT0_IN0 = (/* Pin is configured as SCT0_GPI0 */
IOCON_PIO_FUNC4 |
/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Input filter disabled */
IOCON_PIO_INPFILT_OFF |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT0 PIN24 (coords: M7) is configured as SCT0_GPI0 */
IOCON_PinMuxSet(IOCON, SCTIMER_INITPINS_SCT0_IN0_PORT, SCTIMER_INITPINS_SCT0_IN0_PIN, SCT0_IN0);
}
// Peripheral.c file
const sctimer_config_t SCT0_initConfig = {
.enableCounterUnify = false,
.clockMode = kSCTIMER_System_ClockMode,
.clockSelect = kSCTIMER_Clock_On_Rise_Input_0,
.enableBidirection_l = true,
.enableBidirection_h = false,
.prescale_l = 0U,
.prescale_h = 0U,
.outInitState = (uint8_t)(SCT0_OUTPUT_1),
.inputsync = (uint8_t)(SCT0_INPUTSYNC_0)
};
uint32_t SCT0_event[1];
static void SCT0_init(void) {
SCTIMER_Init(SCT0_PERIPHERAL, &SCT0_initConfig);
/* Initialization of state 0 */
SCTIMER_CreateAndScheduleEvent(SCT0_PERIPHERAL, kSCTIMER_InputRiseEvent, 0, kSCTIMER_Input_0, kSCTIMER_Counter_L, &SCT0_event[0]);
SCTIMER_SetupCounterStartAction(SCT0_PERIPHERAL, kSCTIMER_Counter_L, SCT0_event[0]);
/* Interrupt vector SCT0_IRQn priority settings in the NVIC. */
NVIC_SetPriority(SCT0_IRQN, SCT0_IRQ_PRIORITY);
/* Enable interrupt SCT0_IRQn request in the NVIC. */
EnableIRQ(SCT0_IRQN);
SCTIMER_StartTimer(SCT0_PERIPHERAL, kSCTIMER_Counter_L);
}
/***********************************************************************************************************************
* Initialization functions
**********************************************************************************************************************/
void BOARD_InitPeripherals(void)
{
/* Initialize components */
SCT0_init();
}
/***********************************************************************************************************************
* BOARD_InitBootPeripherals function
**********************************************************************************************************************/
void BOARD_InitBootPeripherals(void)
{
BOARD_InitPeripherals();
}
// main.c file
/*
/**
* @file LPC54628_Project_SCT0_IN0.c
* @brief Application entry point.
*/
#include <stdio.h>
#include "board.h"
#include "peripherals.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "LPC54628.h"
#include "fsl_debug_console.h"
/* TODO: insert other include files here. */
/* TODO: insert other definitions and declarations here. */
/*
* @brief Application entry point.
*/
void SCT0_IN0_IRQ(void)
{
uint32_t Counter =0;
SCTIMER_ClearStatusFlags(SCT0, kSCTIMER_Event0Flag);
Counter = SCT0->CAP[0];
Counter = 0;
}
int main(void) {
/* Init board hardware. */
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitBootPeripherals();
#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL
/* Init FSL debug console. */
BOARD_InitDebugConsole();
#endif
PRINTF("Hello World\n");
/* Force the counter to be placed into memory. */
volatile static int i = 0 ;
/* Enter an infinite loop, just incrementing a counter. */
while(1) {
i++ ;
/* 'Dummy' NOP to allow source level single stepping of
tight while() loop */
__asm volatile ("nop");
}
return 0 ;
}
Advance Thanks
已解决! 转到解答。
Hello,
Please find the AN11538 that contains some code examples that can help you out on the configuration. Please let me know if this was helpful.