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

XMC™ Forum Discussions

Not applicable
Hello,
Because of this is my first post in this forum I want to intruduce myself in a few words.
I'm 17 years old and I'm still going to school visiting the 11th grade. The normal AVR Atmel processors were great to start with but now there are some applications which need some more power. 🙂 Randomly I got an XMC4500 Relaxed Lite Kit and now I'm trying to getting startet with this ARM processor which is something completly new for me.

First I played around a bit with the GPIOs now I'm trying to get a normal PWM working.
I'm using CCU4 Modul 0 slice 0


#include //SFR declarations of the selected device

int main(void)
{
SCU_CLK->CLKSET|= 0b10000; //CCU-CLK enable
//CCU40_CC40 Out Konfig (PORT1.3)
PORT1->IOCR0|= (0b10011< PORT1->PDR0|=(0b0<
CCU40->GIDLC=0b10000001; //Prescaller enable

CCU40_CC40->TC=0b100;//Shadow transfer enable (local)
//Prescaller
CCU40_CC40->PSC=0;//No prescaller 120MHz timer clock
//Period register
CCU40_CC40->PRS=0xFFFF;
//Compare register
CCU40_CC40->CRS=0xFFF;
CCU40->GCSS=1;// Shadow transfer request
CCU40_CC40->TCSET=1; //Run timer
*/
while(1) { }
return 0;
}

I compiled and downloaded the code to the board and checked the output pin with an oscilloscope but I didn't get any output. I started troubleshooting the code and now I'm quite sure that I missed to set some important bits but I don't know which bits are missing.
In this case I don't want to use DAVE Apps because I want to work with the registers and bit fields.

Regards Jannis
0 Likes
1 Reply
Not applicable
Hello again,
I double checked my code from the priveous post with the datasheet and I found some configuration bits I missed to set in the priveous post.
Now the shadow transfer works fine but the timer itself is still not running and I don't know why because I used the recommended initialisation.
Maybe you can help to get this small program working.

int main(void)
{

PORT1->IOCR0|= (0b10011< PORT1->PDR0|= (0b111<
SCU_RESET->PRSET0|= (1< SCU_RESET->PRCLR0|= (1< SCU_CLK->CLKSET= (1< CCU40->GIDLC|=(1< CCU40_CC40->PSC=0; //Prescaller select->0
// Wrong line CCU40_CC40->TCSET=1; //Timer Run Bit set
CCU40_CC40->TC|= (1<
CCU40->GIDLC|= (1< SCU_GENERAL->CCUCON|=(1< CCU40_CC40->TCSET=1; //Timer Run Bit set
CCU40_CC40->PRS=0xFFFF; //Period set
CCU40_CC40->CRS=0xFFF; //Duty Sycle set
CCU40->GCSS|= (1<
while (1){}
return 0;

}


EDIT:
I continued debugging and I found out that the timer run bit hasn't been set. After that I changed the order of the register settings. Now the program works fine.

Regards Jannis
0 Likes