Jump to content

cmb

Members
  • Content Count

    3
  • Joined

  • Last visited


Reputation Activity

  1. Like
    cmb got a reaction from Thorvard in Timer interrupt breaks string functions?   
    I've confirmed that this is a problem somewhere in the toolchain or C library that is packaged with Energia 0101E0009. As I said, I'm developing on Windows XP 32-bit, although I don't know if the problem is specific to this development platform.
     
    I downloaded the GNU embedded ARM package 4.7.4 (from the Launchpad site: https://launchpad.net/gcc-arm-embedded) and replaced these files/directories in the Energia directory structure with the equivalents from the GNU package:
     
    energia-0101E0009/hardware/tools/lm4f/arm-none-eabi/
    energia-0101E0009/hardware/tools/lm4f/bin/*.exe
    Note: the Energia bin/ directory contains two files not in the GNU package: arm-none-eabi-run.exe, and lm4flash.exe. I kept both of these. Also note that the GCC binary is version 4.7.4 rather than 4.7.1, so that executable name is different.
     
    I also copied this library directory from the GNU package...
     
    4.7 2013q2/lib/gcc/arm-none-eabi/4.7.4
     
    ...and put it in two different locations in the Energia tree:
     
    energia-0101E0009/hardware/tools/lm4f/lib/gcc/arm-none-eabi/4.7.4
    energia-0101E0009/hardware/tools/lm4f/libexec/gcc/arm-none-eabi/4.7.4
     
    After doing this, I rebuilt the code that I posted above, and atoi() was working properly. I also added some LED-blinking content to the timer ISR, and a call to strcmp(), and everything was working as expected.
     
    I've only recently started using Energia, so I'm not sure if what I have here constitutes enough for a bug report. Please let me know if I should provide any more information.
     
    --Colin
  2. Like
    cmb got a reaction from Thorvard in Timer interrupt breaks string functions?   
    I'm using Energia with a Launchpad (LM4F120XL), and I've found some strange behavior when using a timer interrupt. When the interrupt setup code is compiled in, functions that do string processing (atoi, strtoul, strtok, etc.) do not return the expected value.

    In the code below, atoi() will return 0 when given the input "12". Note that the timer interrupt hasn't even been set up at the point where atoi() is called. In particular, it's the call to IntRegister() that causes the problem. The same code will work as expected if IntRegister() is commented out.

    Also note that everything works fine if an infinite loop is placed immediately before the initTimer() call -- in that case, I'm guessing the compiler is optimizing out everything in initTimer() because it's unreachable.

    strcmp() was also misbehaving (i.e. returning nonzero values for identical strings), but when I moved the const char* comparison string from global scope to function-level scope, the comparison began working as expected.

    Anyone have any ideas about this? It seems like it might have something to do with the arrangement of symbols in memory.
     
    --Colin
    #include "inc/hw_ints.h" #include "driverlib/sysctl.h" #include "driverlib/interrupt.h" #include "driverlib/timer.h" void timer0_handler(void) { TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); } void initTimer(unsigned Hz) { SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER); unsigned long ulPeriod = (SysCtlClockGet() / Hz) / 2; TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod - 1); IntEnable(INT_TIMER0A); IntRegister(INT_TIMER0A, timer0_handler); TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); IntMasterEnable(); TimerEnable(TIMER0_BASE, TIMER_A); } void setup() { IntMasterDisable(); Serial.begin(9600); } void loop() { const char *dbuf = "12"; Serial.println(atoi(dbuf)); initTimer(3); while (1); }
×
×
  • Create New...