Estoy intentando programar el Stellaris LaunchPad para que parpadee el LED rojo a 1 Hz, impulsado por la interrupción de sysTick. Sin embargo, recibí un error que no he podido resolver.
La fuente C que se me ocurrió tiene este aspecto:
#include "inc/hw_gpio.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_nvic.h"
#include "inc/hw_sysctl.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include <stdint.h>
#define LED_RED GPIO_PIN_1
uint8_t ledState = LED_RED;
void isr( void ) {
ledState ^= ledState; // toggle LED state
ROM_GPIOPinWrite( GPIO_PORTF_BASE , LED_RED , ledState );
}
int main() {
// Set system clock to 80 MHz using PLL and external 16 MHz crystal.
ROM_SysCtlClockSet( SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN );
// Enable GPIO for LED.
ROM_SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOF );
ROM_GPIOPinTypeGPIOOutput( GPIO_PORTF_BASE , LED_RED );
// Enable SysTick at 500 ms and register an interrupt service routine.
ROM_SysTickIntRegister( isr );
ROM_SysTickPeriodSet( 40000000 ); // 80 MHz ÷ 2
HWREG( NVIC_ST_CURRENT ) = 0; // A write to this register reloads the SysTick counter
ROM_SysTickEnable();
ROM_SysTickIntEnable(); // <=
while ( 1 ) {}
}
Y estos son los comandos que utilizo para compilarlo:
arm-none-eabi-gcc \
blink.c \
startup_gcc.c \
-g \
-mthumb \
-mcpu=cortex-m4 \
-mfpu=fpv4-sp-d16 \
-mfloat-abi=softfp \
-Os \
-ffunction-sections \
-fdata-sections \
-MD \
-std=c99 \
-Wall \
-pedantic \
-DPART_LM4F120H5QR \
-c \
-I~/stellaris/stellarisware \
-DTARGET_IS_BLIZZARD_RA1
blink.c: In function 'main':
blink.c:34:2: warning: implicit declaration of function 'ROM_SysTickIntRegister' [-Wimplicit-function-declaration]
ROM_SysTickIntRegister( isr );
^
y para enlazar:
arm-none-eabi-ld \
-T blink.ld \
--entry ResetISR \
-o a.out \
startup_gcc.o \
blink.o \
--gc-sections
blink.o: In function 'main':
~/stellaris/projects/sysTickBlink/blink.c:34: undefined reference to 'ROM_SysTickIntRegister'
El startup_gcc.c se puede encontrar en GitHub: enlace
- ¿Cómo puedo resolver la advertencia y el mensaje de error?
- ¿Por qué tengo que incluir
inc/hw_nvic.hyinc/hw_types.hcuando también se incluye en startup_gcc.c? - ¿Por qué se usa ese
ResetISRdurante el enlace? Lo copié del Makefile en StellarisWare.