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

XMC™ Forum Discussions

Not applicable
Hi,

On my XMC1100 eval board P0.12 and P0.4 is connected through a resistor. I'd like to send data from P0.4 to P0.12 using the code below but the PORT0.IN is not changing in the debugger (PORT0.OUT is changing). What I made wrong?



#include

#include "XMC1100.h"
#include "GPIO.h"

// Ticks are generated every 10ms
#define TICKS_PER_SECOND 100UL


int main(void)
{
// GPIO configuration
P0_4_set_mode(OUTPUT_OD_GP);
P0_12_set_mode(INPUT);

P0_4_reset();

// System Timer initialization
SysTick_Config(SystemCoreClock / TICKS_PER_SECOND);

while(1);
}

void SysTick_Handler(void)
{

P0_4_toggle();

}
0 Likes
5 Replies
chismo
Employee
Employee
First like received
Hello,

When using the open drain output mode, a pull-up resistor to the positive voltage supply is needed. Is this the case in your setup?
Or it would be easier to simply use the output in push-pull mode.

Regards,
Min Wei
0 Likes
Not applicable
Thanks it works.
0 Likes
Not applicable
Now I'd like to count using an external event but it does not work. P0.5 should toggle in every second.
P0.4 toggles using systick, P0.12 and P0.4 connected on eval board through a resistor.
What is wrong?
(The code is based on a DAVE CE Counter code)


#include

#include "XMC1100.h"
#include "GPIO.h"

// Ticks are generated every 10ms
#define TICKS_PER_SECOND 100UL

int main(void)
{
XMC_SCU_UnlockProtectedBits();
SCU_CLK->CGATCLR0 |= SCU_CLK_CGATSTAT0_CCU40_Msk;
XMC_SCU_LockProtectedBits();

// GPIO configuration, P0.4 and P0.12 is connected through a resistor on the eval board
P0_4_set_mode(OUTPUT_PP_GP);
P0_5_set_mode(OUTPUT_PP_AF2); //output for CCU40_CC40
P0_12_set_mode(INPUT);
P0_4_reset();
P0_5_reset();

CCU40->GIDLC |= CCU4_GIDLC_SPRB_Msk; //Prescaler Run Bit Set

CCU40_CC40->CMC = 0x4000; //CNTS: 01B External Count Function triggered by Event 0
CCU40_CC40->INS = 0x420000; //Event 0: 0000B CCU4x.INyA, Signal active on falling edge, Event 0 Level Selection: low

// 1s = 100*10ms, led should blink in every 1s
CCU40_CC40->PSC = 0; //prescaler
CCU40_CC40->PRS = 100; //period value
CCU40_CC40->CRS = 50; //compare value

CCU40->GCSS |= 0x0001; //Slice shadow transfer set enable,

CCU40->GIDLC |= 1; //slice IDLE mode clear
CCU40_CC40->TCSET = CCU4_CC4_TCSET_TRBS_Msk; //Timer Run Bit set

// System Timer initialization
SysTick_Config(SystemCoreClock / TICKS_PER_SECOND);

while(1);
}

void SysTick_Handler(void)
{
P0_4_toggle();
}
0 Likes
chismo
Employee
Employee
First like received
The CCU40_CC40 output on P0.5 is at ALT4, therefore the line:
P0_5_set_mode(OUTPUT_PP_AF2); //output for CCU40_CC40

should be changed to the following instead:
P0_5_set_mode(OUTPUT_PP_AF4); //output for CCU40_CC40
0 Likes
Not applicable
Thanks it works.
0 Likes