XMC4500-Timer Problem

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

cross mob
Not applicable
Hello everyone!

My name is Remy and i am new in this Forum. I am using the XMC4500 and i have a big problem.
I wanted to programm a simple Timer which triggers an Interrupt (in one second two Interrupts) but it doesn't work and i don't know where the Problem is. (I'm not sure if the Timmer runs or the Interrupt is correctly configured)



#include
#include
#include "GPIO.h"


void CCU40_0_IRQHandler(void);


int main(void)
{

P1_1_set_mode(OUTPUT_PP_GP);
P1_1_set_driver_strength(STRONG);
P1_1_reset();



//------CCU4 initalization------
SCU_RESET->PRSET0 |= (1 << SCU_RESET_PRSET0_CCU40RS_Pos );
SCU_RESET->PRCLR0 |= (1 << SCU_RESET_PRCLR0_CCU40RS_Pos);
SCU_CLK-> CLKSET |= (1 << SCU_CLK_CLKSET_CCUCEN_Pos);
CCU40->GIDLC |= (1 << CCU4_GIDLC_SPRB_Pos);
;
CCU40->GIDLC |= (1 << CCU4_GIDLC_CS0I_Pos);
SCU_GENERAL->CCUCON |= (1 << SCU_GENERAL_CCUCON_GSC40_Pos); //CCUCON, that enables a synchronous timer start


//----------TIMER---------
CCU40_CC40->TCSET |=1;
CCU40_CC40->TC |= (1 << CCU4_CC4_TC_TCM_Pos);


//-------------Prescaler --------------
CCU40_CC40->PSC = 0b1010;

//------------Interrupt-----------------
CCU40_CC40->INTE |= (1 << CCU4_CC4_INTE_PME_Pos); //Interrupt Enable
NVIC_EnableIRQ(CCU40_0_IRQn); //Interrupt Enable

}


void CCU40_0_IRQHandler(void)
{
P1_1_toggle();
CCU40_CC40->TCCLR |= (1 << CCU4_CC4_TCCLR_TCC_Pos); //Timer Clear
cnt++;
}






Thank's for help!

Remy
0 Likes
3 Replies
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Hi Renny,

Welcome to this forum. You might like to reference to the below thread link which shows an example of XMC1200 2sec delay example. Please follow the GUI configuration, signal connection and change the MCU to XMC4500.

http://www.infineonforums.com/threads/2335-Re-How-to-generate-2sec-delay-on-xmc1200

Best Regards
Travis
0 Likes
Not applicable
I just need to simply configure a timer and start counting. Please let me know the intialisations and start sequence. I am not able to find it out. No PWM and no other fancy stuff needed.

Sarath
0 Likes
Not applicable
Hi Sarath,

The 'Software_Timers_Init()' function below may be all you need. Just call it in your 'main()' program, add the 'SYSTM001' App into your project and configure it's 'SysTick Interval' for 1mS.

In this example the constant TASK_TIMER_MS is set to 1 to call to my 'TaskScheduler()' function every 1mS. You can change this value to 500.

You can create your own function in place of my 'TaskScheduler()' function to toggle the pin.

Best regards
Aaron

//----------------------------------------------------------------------------
// Setup SYSTICK based software timers using SYSTM001 APP functions.
// Inputs : None
//
// Outputs : None
//
// NOTES : SYSTM001_Init(); // This is called by DAVE_Init()
//
// Originator : Aaron Walsh 19 June 2013
//---------------------------------------------------------------------------
void Software_Timers_Init()
{
handle_t TaskTimerId;


// Configure system timer to call 'TaskScheduler()' function every 1mS
TaskTimerId = SYSTM001_CreateTimer(TASK_TIMER_MS, SYSTM001_PERIODIC, &TaskScheduler, NULL);
if(TaskTimerId != 0)
{
//Timer created successfully so start it
SYSTM001_StartTimer(TaskTimerId);
}
}


0 Likes