infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Page 3 of 3 FirstFirst 1 2 3
Results 21 to 24 of 24

Thread: XMClib POSIF as Quadrature encoder example.

  1. #21
    Beginner Beginner FHK is on a distinguished road
    Join Date
    Nov 2016
    Posts
    4
    Points
    62.5
    Hi,

    the example is really helpful in understanding the use of POSIF. However I'm facing difficulties making it work on a XMC4800 microcontroller.
    As I have to use POSIF1 instead of POSIF0 I changed the corresponding function calls (e.g. XMC_POSIF_Init(POSIF1, &posif_config); instead of XMC_POSIF_Init(POSIF0, &posif_config); ).
    The POSIF still doesn't work because the slices of CCU4 haven't been connected to the correct outputs of POSIF1, they are still connected to POSIF0.

    Code:
    /* Configure CC40 event0 - Count on rising edge of Quadrature Clock (POSIF0.OUT0) */
    	XMC_CCU4_SLICE_CountConfig(SLICE0_PTR, XMC_CCU4_SLICE_EVENT_0);
    	XMC_CCU4_SLICE_ConfigureEvent(SLICE0_PTR, XMC_CCU4_SLICE_EVENT_0, &position_event0_config);
    
    	/* Configure CC40 event1 - Set up count direction on (POSIF0.OUT1) */
    	XMC_CCU4_SLICE_DirectionConfig(SLICE0_PTR, XMC_CCU4_SLICE_EVENT_1);
    	XMC_CCU4_SLICE_ConfigureEvent(SLICE0_PTR, XMC_CCU4_SLICE_EVENT_1, &position_event1_config);
    
    	/* Configure CC41 event0 - Count on rising edge of POSIF index signal */
    	XMC_CCU4_SLICE_CountConfig(SLICE1_PTR, XMC_CCU4_SLICE_EVENT_0);
    	XMC_CCU4_SLICE_ConfigureEvent(SLICE1_PTR, XMC_CCU4_SLICE_EVENT_0, &revolution_event0_config);
    
    	/* Configure CC41 event1 - Set up count direction on (POSIF0.OUT1) */
    	XMC_CCU4_SLICE_DirectionConfig(SLICE1_PTR, XMC_CCU4_SLICE_EVENT_1);
    	XMC_CCU4_SLICE_ConfigureEvent(SLICE1_PTR, XMC_CCU4_SLICE_EVENT_1, &revolution_event1_config);
    
    	/* Configure CC42 event0 - Count on rising edge of Period Clock (POSIF0.OUT2) */
    	XMC_CCU4_SLICE_CountConfig(SLICE2_PTR, XMC_CCU4_SLICE_EVENT_0);
    	XMC_CCU4_SLICE_ConfigureEvent(SLICE2_PTR, XMC_CCU4_SLICE_EVENT_0, &tick_event0_config);
    
    	/* Configure CC42 event1 - Set up external flush and start on POSIF index signal */
    	XMC_CCU4_SLICE_StartConfig(SLICE2_PTR, XMC_CCU4_SLICE_EVENT_1, XMC_CCU4_SLICE_START_MODE_TIMER_START_CLEAR);
    	XMC_CCU4_SLICE_ConfigureEvent(SLICE2_PTR, XMC_CCU4_SLICE_EVENT_1, &tick_event1_config);
    My question is: What do I have to change to connect the slices of the timer to POSIF1?

    I guess I have to change these definitions in the file xmc_ccu4_map.h

    #
    Code:
    define XMC_CCU4_SLICE_INPUT_A (0U)
    #define XMC_CCU4_SLICE_INPUT_B (1U)
    #define XMC_CCU4_SLICE_INPUT_C (2U)
    #define XMC_CCU4_SLICE_INPUT_D (3U)
    #define XMC_CCU4_SLICE_INPUT_E (4U)
    #define XMC_CCU4_SLICE_INPUT_F (5U)
    #define XMC_CCU4_SLICE_INPUT_G (6U)
    #define XMC_CCU4_SLICE_INPUT_H (7U)
    #define XMC_CCU4_SLICE_INPUT_I (8U)
    #define XMC_CCU4_SLICE_INPUT_J (9U)
    #define XMC_CCU4_SLICE_INPUT_K (10U)
    #define XMC_CCU4_SLICE_INPUT_L (11U)
    #define XMC_CCU4_SLICE_INPUT_M (12U)
    #define XMC_CCU4_SLICE_INPUT_N (13U)
    #define XMC_CCU4_SLICE_INPUT_O (14U)
    #define XMC_CCU4_SLICE_INPUT_P (15U)
    But in what manner do I have to change the definitions?
    Any help is really apreciated! Thanks!

  2. #22
    Beginner Beginner FHK is on a distinguished road
    Join Date
    Nov 2016
    Posts
    4
    Points
    62.5
    Hi,

    the example is really helpful for understanding the use of the POSIF interface. However I have a question. I'm trying to use the POSIF Interface on a XMC 4800. As I have to use POSIF 1 instead of POSIF0, I changed the function calls correspondingly.
    Eg:

    Code:
       XMC_POSIF_Init(POSIF1, &posif_config);
    instead of

    Code:
       XMC_POSIF_Init(POSIF0, &posif_config);
    So far the POSIF Interface still doesn't work and I assume it is because the mapping of the POSIF outputs to the CCU4 slices hasn't been changed:

    Code:
    /* Configure CC40 event0 - Count on rising edge of Quadrature Clock (POSIF0.OUT0) */
    	XMC_CCU4_SLICE_CountConfig(SLICE0_PTR, XMC_CCU4_SLICE_EVENT_0);
    	XMC_CCU4_SLICE_ConfigureEvent(SLICE0_PTR, XMC_CCU4_SLICE_EVENT_0, &position_event0_config);
    
    	/* Configure CC40 event1 - Set up count direction on (POSIF0.OUT1) */
    	XMC_CCU4_SLICE_DirectionConfig(SLICE0_PTR, XMC_CCU4_SLICE_EVENT_1);
    	XMC_CCU4_SLICE_ConfigureEvent(SLICE0_PTR, XMC_CCU4_SLICE_EVENT_1, &position_event1_config);

    The inputs of the slices of CCU4 seem to be defined in the file config_ccu4.h:

    Code:
    XMC_CCU4_SLICE_EVENT_CONFIG_t position_event0_config =
    {
    	.mapped_input = XMC_CCU4_SLICE_INPUT_E, /* mapped to POSIF0.OUT0 - POSITION tick */
    	.edge = XMC_CCU4_SLICE_EVENT_EDGE_SENSITIVITY_RISING_EDGE,
    	.level = XMC_CCU4_SLICE_EVENT_LEVEL_SENSITIVITY_COUNT_UP_ON_HIGH,
    	.duration = XMC_CCU4_SLICE_EVENT_FILTER_DISABLED
    };
    What do I have to do to change the input of the slice so the signal from POSIF1 is routed to the slice?

    Any help is apreciated! Thanks!

  3. #23
    New Member New Member DaveUser16 is on a distinguished road
    Join Date
    Oct 2016
    Posts
    4
    Points
    42.5
    I use an incremental encoder, and try to use the index signal to reset the position count to prevent the position error accumulation problem. The index signal is connected to the CCU41 event0. I detected it happens with an oscilloscope. I use following code to setup the interrupt.
    /* Enable CC41 event */
    XMC_CCU4_SLICE_EnableEvent(SLICE1_PTR, XMC_CCU4_SLICE_IRQ_ID_EVENT0);

    /* Connect capture on CC41 event 0 to SR0 */
    XMC_CCU4_SLICE_SetInterruptNode(SLICE1_PTR, XMC_CCU4_SLICE_IRQ_ID_EVENT0, XMC_CCU4_SLICE_SR_ID_0);

    /* Set NVIC priority */
    NVIC_SetPriority(CCU41_0_IRQn, 3U);

    /* Enable IRQ */
    NVIC_EnableIRQ(CCU41_0_IRQn);

    The interrupt service routine:
    void CCU41_0_IRQHandler(void)
    {
    /* Clear pending interrupt */
    XMC_CCU4_SLICE_ClearEvent(SLICE1_PTR, XMC_CCU4_SLICE_IRQ_ID_EVENT0);

    // Reset position count
    XMC_CCU4_SLICE_SetTimerValue(SLICE0_PTR, 0);
    }

    However, the interrupt never happens. Does anyone can help me to find what I did wrong? I appreciate any suggestion to make it work.

    Regards,
    Yaoxin

  4. #24
    Beginner Beginner Carlos_Almeida is on a distinguished road
    Join Date
    Aug 2018
    Posts
    2
    Points
    60
    Hi, I'm having the same problem as Yaoxin, where the interrupt never happens.
    Im using a XMC4500, where the only thing I changed from the example given by Daryl Neo was the following lines of code

    code in main:
    XMC_GPIO_Init(P1_3, &posif_encoder_inputport_config); /* A */
    XMC_GPIO_Init(P1_2, &posif_encoder_inputport_config); /* B */
    XMC_GPIO_Init(P1_1, &posif_encoder_inputport_config); /* index */
    code in config_posif.h
    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 */
    };
    Everything else is equal to the example given, but my code never enters the interrupt and I really can´t understand why, is there something else I need to change to have POSIF working in the pins I'm using?

    Any help is greatly appreciated. I really don't know what is wrong

    Regards,
    Carlos

+ Reply to Thread

Tags for this Thread

Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.