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.
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.
Well I know how and where to declare a function, but I get the same errors: http://imgur.com/0dNfIEQ .
Not sure if you realize it, but I bet quite a number of people are doing what I'm doing - ignoring all your links to screen shots or whatever they may be.
Anything wrong with posting the error messages as text? It has worked will for thousands of other people on this forum. Or maybe I'm just not part of the Youtube generation where the only way to learn seems to be by viewing Youtube videos.
The formatting gets messed up when I copy my code into here from uVision as you can see:
#include "stdio.h" #include "XMC4500.h" //SFR declarations of the selected device #include "xmc_gpio.h" uint32_t msTicks = 0; /* Variable to store millisecond ticks */ void SysTick_Handler(void) { /* SysTick interrupt Handler.*/ msTicks++; /*See startup file startup_XMC4500.s for SysTick vector */ if (msTicks & 1) // 2ms period, 500 Hz on scope PORT3->OMR = 0x00000080UL; // 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, PORT3->OMR = 0x00800000UL; // if even, signal to pin goes LOW. This completes our 2ms/500Hz cycle. } int main (void) { uint32_t returnCode; EnableGPIOPeripheralClock(1); PORT3->OMR = 0x00000080UL; 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); }
My only remaining error is .\Objects\sadsadsa.axf: Error: L6218E: Undefined symbol EnableGPIOPeripheralClock (referred from maaaaaain.o). .
I am still looking for a way to enable the gpio peripheral clock. I think this is much easier to follow: http://imgur.com/550uCUC .
Here is my code now:
#include "stdio.h" #include "XMC4500.h" //SFR declarations of the selected device #include "xmc_gpio.h" #include "xmc4_gpio.h" uint32_t msTicks = 0; /* Variable to store millisecond ticks */ void SysTick_Handler(void) { /* SysTick interrupt Handler.*/ msTicks++; /*See startup file startup_XMC4500.s for SysTick vector */ if (msTicks & 1) // 2ms period, 500 Hz on scope PORT3->OMR = 0x00000080UL; // 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, PORT3->OMR = 0x00800000UL; // if even, signal to pin goes LOW. This completes our 2ms/500Hz cycle. } int main (void) { uint32_t returnCode; PORT3->IOCR[P3_7 >> 2U] P3_7_set_driver_strength(STRONG); PORT3->OMR = 0x00800000UL; 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); }
but I am getting the error :
maaaaaain.c(21): error: #136: struct "<unnamed>" has no field "IOCR" PORT3->IOCR[P3_7 >> 2U]
any ideas on how to fix this?
Maybe stop trial-and-error coding and spend some time reading through the available reference documentation?
You may also read through the header files to see exactly what structures and functions that are mentioned.
Copying random code will not do you any good. And you need to be way more careful too - that line doesn't even have any terminating ';'.
How well will your:
// Error Handling
actually manage, in case there is an error? Why pretend to check the error code if you don't handle it anyway?
I would suggest that you get a suitable book and walk through basic C programming on a PC before you return to embedded programming. Right now, you seem to have taken on a much too big task that you lack the required strategy to solve yourself.
I have done C many times in the past. I am just trying to delve into ARM programming. I have programmed many proprietary architectures before ARM where setting up a timer and GPIOs was much easier. I have looked at the Infineon manual for this specific MCU and it is very hard to follow.
I have done C many times in the past.
I'd be interested to know what you did in C before.
You didn't know about the simple concept of masking to determine odd or even and it appears that you didn't know where to add functions.
It's even questionable as to whether any of what you've asked is specific to ARM.
I can only conclude that those C projects you did must have been rather limited.
You really should go back to basics.
I am looking for a way to enable the GPIO pin and its clock. I have looked through the MCU reference manual, I have looked through all the header files,etc and I have found nothing that states how to do this for the XMC4500 MCU. I find it odd that I am not able to find a simple example like www2.keil.com/docs/default-source/default-document-library/mdk5-getting-started.pdf#page=54 for my Cortex M4 MCU.
If you have experience in C - don't you then find it odd, that you are using a field IOCR, when the header file (that you have spent time looking through) seems to indicate that the available fields looks like:
typedef struct { /*!< (@ 0x48028300) PORT3 Structure */ __IO uint32_t OUT; /*!< (@ 0x48028300) Port 3 Output Register */ __O uint32_t OMR; /*!< (@ 0x48028304) Port 3 Output Modification Register */ __I uint32_t RESERVED0[2]; __IO uint32_t IOCR0; /*!< (@ 0x48028310) Port 3 Input/Output Control Register 0 */ __IO uint32_t IOCR4; /*!< (@ 0x48028314) Port 3 Input/Output Control Register 4 */ __IO uint32_t IOCR8; /*!< (@ 0x48028318) Port 3 Input/Output Control Register 8 */ __IO uint32_t IOCR12; /*!< (@ 0x4802831C) Port 3 Input/Output Control Register 12 */ __I uint32_t RESERVED1; __I uint32_t IN; /*!< (@ 0x48028324) Port 3 Input Register */ __I uint32_t RESERVED2[6]; __IO uint32_t PDR0; /*!< (@ 0x48028340) Port 3 Pad Driver Mode 0 Register */ __IO uint32_t PDR1; /*!< (@ 0x48028344) Port 3 Pad Driver Mode 1 Register */ __I uint32_t RESERVED3[6]; __I uint32_t PDISC; /*!< (@ 0x48028360) Port 3 Pin Function Decision Control Register */ __I uint32_t RESERVED4[3]; __IO uint32_t PPS; /*!< (@ 0x48028370) Port 3 Pin Power Save Register */ __IO uint32_t HWSEL; /*!< (@ 0x48028374) Port 3 Pin Hardware Select Register */ } PORT3_Type;
Where is that IOCR field? I can't find it. The compiler can't find it. Where did you find it?
Next thing - you use IOCR as if it was an array. The above struct indicates that the IOCR0, IOCR4, IOCR8 and IOCR12 fields are 32-bit integers.
Maybe your header file is different from: http://www.keil.com/dd/docs/arm/infineon/xmc4500/xmc4500.h
But I wouldn't know, since you haven't shown us exactly why you feel your code is correct and the compiler is wrong.
The reference manual for XMC4500 is 20 MB large. Why? Because it contains a lot of information. It isn't possible to survive on sample code - real programming requires reading of the actual reference documentation.
And since the reference documentation of a processor isn't written in the language of header files, the developer will then have to write their own header files, or spend time looking through the header files supplied with the tool chain or by the chip manufacturer, and see exactly how the information in the documentation has been packaged into structures and what flags that have been given names in form of #define or enum and what flag fields the developer will have to label themselves.
The important thing is that the documentation is splitted into chapters - so it isn't neccessary to read every single sentence. But it is important to know how to scan the reference documentation like a dictionary to pick up the individual facts that relates to different parts of the hardware functionality. No sample code will ever get close, unless the processor was totally trivial. The GPIO chapter is about 43 pages - how could sample code cover this amount of information? But it would be enough to spend an hour with this chapter to know what information there is - and then know what pages to look at again to actually make use of the GPIO functionality.
If you think 43 pages is too much, then you need to consider a processor will less number of pages in the reference documentation. So go for a much simpler processor - and at the same time being limited to less possible functionality. Everything has its price.
I will try to read through that section on GPIO and see if I can set up the clock and enable the pin. This is a little difficult for someone new to embedded MCU progrmaming, but this is the board I got. I was hoping to find an example specifically to this MCU on how to set the clock and enable the pin, but unfortunately it is not out there.
Note that clocking is often a separate chapter.
Hi Per. I found this: embeddedplaygroup.wordpress.com/.../ project where it looks like there is a section on configuring ports/pins. Do you think this would be a good resource to take a look at?
Per, so essentially what I have to do is:
1.) Set pin 3.7 to output in 'push pull' mode 2.) Set pad driver for pin 3.7 to 'strong'
So here is what I have now (builds with no errors/warnings):
#include "stdio.h" #include "XMC4500.h" //SFR declarations of the selected device #include "xmc_gpio.h" #include "xmc4_gpio.h" uint32_t msTicks = 0; /* Variable to store millisecond ticks */ void SysTick_Handler(void) { /* SysTick interrupt Handler.*/ msTicks++; /*See startup file startup_XMC4500.s for SysTick vector */ // Set GPIO to alternate between HIGH/LOW if (msTicks & 1) // 2ms period, 500 Hz on scope PORT3->OMR = 0x00000080UL; // 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, PORT3->OMR = 0x00800000UL; // if even, signal to pin goes LOW. This completes our 2ms/500Hz cycle. } int main (void) { uint32_t returnCode; PORT3->IOCR0 = 0x80UL << 0; // P3.7 output, push pull PORT3->PDR0 = 0x02UL << 0; // P3.7 pad driver strong 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); }
I am still not sure how to go about error handling, but what do you think about what I have regarding my configurations of the GPIO?