This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Generating a 1ms heartbeat timer on XMC4500.

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.

Parents
  • 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.

Reply
  • 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.

Children
  • 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?