Announcements

Help us improve the Power & Sensing Selection Guide. Share feedback

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hi all,

im using the posif module and an incremental encoder to do an ap with XMC1300 boot kit

i want to do generate an interrupt with the index signal. These are the signals of my encoder:
2576.attach

i think that i forget something because yhe interrupt is not working. can someone help?

this is my code:

#include
#include
#include
#include

#define A_POSIF P1_2
#define B_POSIF P1_1
#define I0_POSIF P1_0

XMC_SCU_CLOCK_CONFIG_t clock_config;
XMC_GPIO_CONFIG_t led1_config;

XMC_POSIF_CONFIG_t posif_config =
{
.mode = XMC_POSIF_MODE_QD, /**< POSIF Operational mode */
.input0 = XMC_POSIF_INPUT_PORT_A, /**< Choice of input for Input-1 */
.input1 = XMC_POSIF_INPUT_PORT_A, /**< Choice of input for Input-2 */
.input2 = XMC_POSIF_INPUT_PORT_A, /**< Choice of input for Input-3 */
.filter = XMC_POSIF_FILTER_DISABLED, /**< Input filter configuration */
};

/* Defines POSIF quadrature decoder initialization data structure. */
XMC_POSIF_QD_CONFIG_t posif_qd_config =
{
.mode = (XMC_POSIF_QD_MODE_t)XMC_POSIF_QD_MODE_QUADRATURE,
.phase_a = 0U, /* Phase A is active High */
.phase_b = 0U, /* Phase B is active High */
.phase_leader = 0U, /* Phase A is the leading signal for clockwise rotation */
.index = 0U /* No index marker generation on POSIF0.OUT3 */
};

/* GPIO Init handle for input Pin */
/* Port 14 digital pad input is disabled by default, this is to enable the digital pad input */
XMC_GPIO_CONFIG_t posif_encoder_inputport_config =
{
.mode = XMC_GPIO_MODE_INPUT_PULL_UP,
.output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH,
};



void POSIF0_0_IRQHandler (void){
XMC_POSIF_ClearEvent(POSIF0, XMC_POSIF_IRQ_EVENT_INDX);

XMC_GPIO_ToggleOutput(XMC_GPIO_PORT0,6);
}


int main(void)
{
/* Configure Clock */
clock_config.pclk_src = XMC_SCU_CLOCK_PCLKSRC_MCLK; /*PCLK = MCLK*/
clock_config.fdiv = 0; /**< Fractional divider */
clock_config.idiv = 0; /**MCLK = 32MHz */

XMC_SCU_CLOCK_Init(&clock_config);

/* Configure LED1 */
led1_config.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL;
led1_config.output_level = XMC_GPIO_OUTPUT_LEVEL_LOW;
XMC_GPIO_Init(XMC_GPIO_PORT0,6, &led1_config);

/* POSIF Initialization */
XMC_POSIF_Init(POSIF0, &posif_config);
XMC_POSIF_QD_Init(POSIF0, &posif_qd_config);

/* GPIO initialization to enable digital pad input */
XMC_GPIO_Init(A_POSIF, &posif_encoder_inputport_config); /* A */
XMC_GPIO_Init(B_POSIF, &posif_encoder_inputport_config); /* B */
XMC_GPIO_Init(I0_POSIF, &posif_encoder_inputport_config); /* index */

/* IRQ config */
XMC_POSIF_SetInterruptNode(POSIF0, XMC_POSIF_IRQ_EVENT_INDX, XMC_POSIF_SR_ID_0);
XMC_POSIF_EnableEvent(POSIF0, XMC_POSIF_IRQ_EVENT_INDX);

NVIC_EnableIRQ(POSIF0_0_IRQn);
NVIC_SetPriority(POSIF0_0_IRQn, 3U);

XMC_POSIF_Start(POSIF0);

while(1U)
{

}
}


thanks for all.
0 Likes
0 Replies