Configuring a GPIO on the XMC4500 hex with PIN extension card.

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

cross mob
Not applicable
Hi, all. I have created a 1ms SysTick timer and need a way to verify that it indeed works. So I have been taking a look at the reference manual for the XMC4500 and found some interesting stuff regarding configuring a GPIO to be an output. In this case, I want the GPIO to be my 1ms systick timer.

Here is my configuration: http://imgur.com/0ue0MRt . As you can see I have attached the Pin Extension Card to the main board so that I can have a GPIO to attach an oscilloscope probe to.

I found this: http://imgur.com/p4mDG0o in the reference manual which shows where each pin of the Pin Extension Card is connected to on the MCU. I have decided to go with Pin 41 'COM_GPIO0' as my output for the 1ms systick timer.

Now, I am having trouble figuring out how to code that pin as my output. I only found these steps: http://imgur.com/qiMa6w2 , but it is hard to follow without an example. Hopefully someone can chime in on how I can set GPIO High, set GPIO Low, enable GPIO peripheral clock, enable GPIO pin which you can see there is just pseudo-code for now. Or is there a simpler way to verify my SysTick timer is working properly?

My code in Keil uVision:

#include 
#include //SFR declarations of the selected device

volatile uint32_t msTicks = 0; /* Variable to store millisecond ticks */

void SysTick_Handler(void) // Entering every 1 ms (1 KHz)
{ /* SysTick interrupt Handler.
msTicks++; See startup file startup_XMC4500.s for SysTick vector */

// Pseudo-code

// if (msTicks & 1) // 2ms period, 500 Hz on scope
// SetGPIOHigh(); // 7 & 1 is 1; 8 & 1 is 0 -- bitwise operation, so basically we are just looking at the least
// else // significant count to determine whether it's odd or even. If odd, signal to pin goes HIGH,
// SetGPIOLow(); // if even, signal to pin goes LOW. This completes our 2ms/500Hz cycle.
}

int main (void)
{
uint32_t returnCode;

// Pseudo-code

// EnableGPIOPeripheralClock();
// EnableGPIOPin();

returnCode = SysTick_Config(SystemCoreClock / 1000); /* Configure SysTick to generate an interrupt every millisecond */

if (returnCode != 0) { /* Check return code for errors */
// Error Handling
}

while(1);
}
0 Likes
0 Replies