Hi all. Just as the title says, I am trying to generate a 1ms heartbeat timer on my XMC4500 hexagon board, but I am running into an error which you can see here: http://imgur.com/o5TGwms .
You can see there at the bottom in Build Output that I am getting the L6200E Error. Now, the reason it says .\Flash\Blinky.axf in front of the error is because I simply opened up the example Blinky project and deleted the contents of Source Files folder and replaced it with the sysTick.c code.
Any help is much appreciated.
Here is system_XMC4500.c: gist.github.com/.../9d53320e88c9114a0d17
Here is startup_XMC4500.s: gist.github.com/.../bce8d21af5019e816f97
What are your thoughts now, Pier? Do you think I will be generating a 1ms systick timer?
I think you need to take some responsibility to test/evaluate this yourself. I haven't read the manual for your part, and don't have the board.
You are right, Pier. My next step would be to somehow test the board and see if I am truly generating a 1ms systick timer.
You mentioned several ways I can do this, but which way do you think would be the easiest/most efficient considering the board I am using?
With an oscilloscope or frequency counter.
Pier, I understand what you meant by turning on a GPIO at every 1ms tick, I am just having a hard time figuring out where in my current code to add the additional code to toggle the GPIO? How do you think I should approach this?
The best approach is to start reading code interleaved with reading the documentation for the processor and the OS and the runtime library. Continue reading until you understand what the code does - and how it does it. You can't get further if everything you see is just some black magic.
Hi, Per. 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. Could you help me figure this out, or do you know of any examples I could try to follow?
I think you'd want to review example materials from Infineon
#include <stdio.h> #include <XMC4500.h> //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(); // else // SetGPIOLow(); } 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); }
Hi, Pier. Where did you find this code, or did you come up with it yourself? I need some more information to help me make sense about what the commented-out pseudocode is doing.
I am especeially interested in knowing what the following pseudo-code is doing. Could you explain it a little more, Pier? How does 'msTicks & 1' generate a 2ms period and thus 500Hz?
// Pseudo-code // if (msTicks & 1) // 2ms period, 500 Hz on scope // SetGPIOHigh(); // else // SetGPIOLow();
msTicks gets incremented each ms.
on odd tick, high is called. on even tick, low is called.
so a high low cycle occurs with 2 of the msTicks
so the frequency is 500ms
easy. no?
Hi, sudo. I understand this, but how does 'msTicks & 1' get this done? To me '&' is just a bitwise AND operator.
EDIT:
So lets say msTicks is 7, then 7 & 1 = 7. Which is odd, so signal to pin goes HIGH. Then lets say msTicks is 8, then 8 & 1 = 8. Which is even, so signal to pin goes LOW. This completes our 2ms/500Hz cycle.
Is this how it works?
nearly.
7 & 1 is 1 8 & 1 is 0
the & is a bitwise operator
so, basically, you're just looking at the least significant bit of the count to determine whether it's odd or even.
Hi, sudo. So here is what I have: http://imgur.com/FzL2k8I .
I knew I was going to get those errors. I simply have not declared the functions. How and where do you think should I declare these functions, because this could be done in several ways?
if you don't know where to declare a function, you'd better go back to the first lesson of programming in C.