Jump to content

cmb

Members
  • Content Count

    3
  • Joined

  • Last visited

Everything posted by cmb

  1. 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. It seems like this is probably a compiler (or framework) bug. Switching to the ROM_ functions for timer interrupt setup did not have any effect. I haven't tried a different compiler/environment, but I would definitely like to continue using Energia if anyone could find a workaround for this problem. The code below is sufficient to reproduce the problem (using Energia 0101E0009, running on Windows XP 32-bit). #include "driverlib/timer.h" void timer_isr(void) { TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); } void setup() { Serial.begin(9600); } void loop() { const char *dbuf = "12"; Serial.println("-----"); Serial.println(atoi(dbuf)); // this will print '0' instead of '12' Serial.println("-----"); // removing the following line causes atoi() to work normally TimerIntRegister(TIMER0_BASE, TIMER_A, timer_isr); while (1); }
  3. 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...