Hi All.
I had been making some changes to the tiva-blinky example, on the Tiva-Launchpad board.
The code is as follows ::
#include <stdbool.h> #include <stdint.h> #include <string.h> #include "src/common/include/globals.h" #include "inc/hw_types.h" #include "inc/hw_gpio.h" #include "inc/hw_memmap.h" #include "inc/hw_sysctl.h" #include "driverlib/gpio.h" #include "driverlib/rom.h" #include "driverlib/sysctl.h" #include "driverlib/pin_map.h" #include "driverlib/can.h" #define LED_RED GPIO_PIN_1 #define LED_BLUE GPIO_PIN_2 #define LED_GREEN GPIO_PIN_3 int main() { char m[100]; SG_MEMSET(m, 0, 100) ROM_SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, LED_RED|LED_BLUE|LED_GREEN); for (;;) { // set the red LED pin high, others low ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED|LED_GREEN|LED_BLUE, LED_BLUE); ROM_SysCtlDelay(5000000); ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED|LED_GREEN|LED_BLUE, 0); ROM_SysCtlDelay(5000000); } }
Now, two cases arise ::
a)
SG_MEMSET is
#define SG_MEMSET(dest, byte, size) \ { \ char temp[MAX_BUFFER_SIZE] = {byte}; \ memcpy(dest, temp, size); \ }
In this "inlining" case, the BLUE light blinks fine as expected.
b)
SG_MEMSET is
void DO_SG_MEMSET(char *dest, char byte, unsigned int size) { char temp[MAX_BUFFER_SIZE] = {byte}; memcpy(dest, temp, size); } #define SG_MEMSET(dest, byte, size) DO_SG_MEMSET(dest, byte, size);
In this "normal-function-calling" case, no light blinks :(
I am at a complete-loss why this could be happening.
Are multiple-frames/function-calling disabled on Tiva-Launchpad?
For brevity, here is the linker-script being used ::
MEMORY { FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0X00008000 } SECTIONS { /* code */ .text : { _text = .; /* ensure ISR vectors are not removed by linker */ KEEP(*(.isr_vector)) *(.text*) *(.rodata*) _etext = .; } > FLASH /* static data */ .data : AT(ADDR(.text) + SIZEOF(.text)) { _data = .; *(vtable) *(.data*) _edata = .; } > SRAM /* static uninitialized data */ .bss : { _bss = .; *(.bss*) *(COMMON) _ebss = .; } > SRAM }
Will be grateful for any pointers. I cannot move forward before resolving this very basic issue :-\
Thanks and Regards,
Ajay