cancel
Showing results for 
Search instead for 
Did you mean: 

symbol _GPIO_Init not defined (Debug\main.o )

MQi.1
Senior II

I tried the example code in this document - dm00405517-getting-started-with-the-stm8s001j3-microcontroller-stmicroelectronics.pdf, the code was:

//Recommendation for STM8S001J3 firmware AN5047 12/20 Rev 2
/* MAIN.C file */
#include "stm8s.h"
#include "stm8s_gpio.h"
#include "stm8s_clk.h"
#ifdef _COSMIC_
 #define ASM _asm
#endif
#ifdef _IAR_
 #define ASM asm
#endif
/* This delay should be added just after reset to have access to SWIM pin 
and to be able to reprogram the device after power on (otherwise the device 
will be locked) */
#define STARTUP_SWIM_DELAY_5S \
 { \
 ASM(" PUSHW X \n" \
 " PUSH A \n" \
 " LDW X, #0xFFFF \n" \
 "loop1: LD A, #50 \n" \
 \
 "loop2: DEC A \n" \
 " JRNE loop2 \n" \
 \
 " DECW X \n" \
 " JRNE loop1 \n" \
 \
 " POP A \n" \
 " POPW X " ); \
 }
/* not connected pins as output low state (the best EMC immunity) 
(PA2, PB0, PB1, PB2, PB3, PB6, PB7, PC1, PC2, PC7, PD0, PD2, PD4, PD7, PE5, PF4) */
#define CONFIG_UNUSED_PINS_STM8S001 \
{ \
 GPIOA->DDR |= GPIO_PIN_2; \
 GPIOB->DDR |= GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_6 | GPIO_PIN_7; \
 GPIOC->DDR |= GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7; \
 GPIOD->DDR |= GPIO_PIN_0 | GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_7; \
 GPIOE->DDR |= GPIO_PIN_5; \
 GPIOF->DDR |= GPIO_PIN_4; \
}
/* pin for testing */
#define TEST_PORT GPIOA
#define TEST_PIN GPIO_PIN_3
//#define HSE_TEST
 
 
/* Example of firmware for STM8S001: recommended startup + test of pins functionality */
main()
{
 /* -------------STM8S001 startup-------------- */
 /* configure unbonded pins */
 CONFIG_UNUSED_PINS_STM8S001;
 /* delay for SWIM connection: ~5seconds */
 STARTUP_SWIM_DELAY_5S;
 /* ------------------------------------------- */
 
 /* configure all STM8S001 pins as input with pull up */
 GPIO_Init(GPIOA, GPIO_PIN_1, GPIO_MODE_IN_PU_NO_IT); // pin 1
 GPIO_Init(GPIOA, GPIO_PIN_3, GPIO_MODE_IN_PU_NO_IT); // pin 5
 GPIO_Init(GPIOB, GPIO_PIN_4, GPIO_MODE_OUT_PP_LOW_FAST); // pin 6 (PB4 has no pull-up - configure it as output low)
 GPIO_Init(GPIOC, GPIO_PIN_3, GPIO_MODE_IN_PU_NO_IT); // pin 7
 GPIO_Init(GPIOC, GPIO_PIN_6, GPIO_MODE_IN_PU_NO_IT); // pin 8
 
 /* disable peripherals clocks to decrease consumption */
 CLK->PCKENR1 = 0x00;
 CLK->PCKENR2 = 0x00;
 
 /* for testing external HSE clock */ 
 /* make sure that option bit EXTCLK=1 */
 #ifdef HSE_TEST
 /* test HSE (external clock) - apply input clock on PA1 (pin 1) */
 GPIO_Init(GPIOC, GPIO_PIN_4, GPIO_MODE_OUT_PP_LOW_FAST); // CCO is on PC4 (pin 7)
 CLK_CCOConfig(CLK_OUTPUT_CPU); // clock out on PC4/CCO (pin 7)
 CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSE, DISABLE,
 CLK_CURRENTCLOCKSTATE_DISABLE); //set HSE as clock
 #endif //HSE_TEST
 
 /* initialize tested pin */
 GPIO_Init(TEST_PORT, TEST_PIN, GPIO_MODE_OUT_PP_LOW_FAST);
 
 while (1)
 {
 /* toggle with tested pin */
 GPIO_WriteReverse(TEST_PORT, TEST_PIN);
 }
}

I could compile it in STVD:

----------- Project test_stm8s001j3 - STM8 Cosmic - Configuration Debug -------------
 
Compiling main.c...
cxstm8 -if:\stm8\stm8s_stdperiph_lib\libraries\stm8s_stdperiph_driver\inc +debug -pxp -no -l +mods0 -pp -iF:\CXSTM8\Hstm8  -clDebug\ -coDebug\ main.c 
main.c:
 
main.o - 0 error(s), 0 warning(s)

while, I couldn't build it:

----------- Project test_stm8s001j3 - STM8 Cosmic - Configuration Debug -------------
 
Running Linker
clnk -m Debug\test_stm8s001j3.map -lF:\CXSTM8\Lib  -o Debug\test_stm8s001j3.sm8 Debug\test_stm8s001j3.lkf 
#error clnk Debug\test_stm8s001j3.lkf:1 symbol _GPIO_Init not defined (Debug\main.o )
#error clnk Debug\test_stm8s001j3.lkf:1 symbol _GPIO_WriteReverse not defined (Debug\main.o )
 The command: "clnk -m Debug\test_stm8s001j3.map -lF:\CXSTM8\Lib  -o Debug\test_stm8s001j3.sm8 Debug\test_stm8s001j3.lkf " has failed, the returned value is: 1
exit code=1.
 
test_stm8s001j3.elf - 4 error(s), 0 warning(s)

does anyone know the reason?

1 REPLY 1
MQi.1
Senior II

I found the reason: I haven't included the "stm8s_gpio.c".