cancel
Showing results for 
Search instead for 
Did you mean: 

Using the inline compiling macro ?

T J
Lead

I have an LCD is on an 8080 16bit FMC interface with A0 register select.

I can read the status correctly here:

#define LCD1_DEVICE_ADDR (uint32_t)0x60000000
#define LCD1_DEVICE_DATA (uint32_t)0x60000001
 
   uint16_t *pLcdRStatusWAddress = LCD1_DEVICE_ADDR;
   readLcdStatus = *pLcdRStatusWAddress;
 
 

All of these snippets are within one file,

//this compiles:
 
inline lcdRegDataWrite(uint8_t reg, uint8_t data) {
   *(__IO uint16_t*)LCD1_DEVICE_ADDR = reg;        
   *(__IO uint16_t*)LCD1_DEVICE_DATA = data;       
} 
 
//but this doesn't find it
 
   lcdRegDataWrite( 1 , 8);
 
>>> undefined reference to `lcdRegDataWrite'
 
 

13 REPLIES 13
Amel NASRI
ST Employee

Hi @Community member​ ,

Could you please provide more details on your case: which compiler? which device? is this your own code or found in an example provided by ST?...

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Check with your compiler vendor, review example others are using and that work

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
T J
Lead

this is the full compiler output...

1>------ Build started: Project: TH218_sln, Configuration: Debug Win32 ------
1>VisualGDB: Run "C:\SysGCC\arm-eabi\bin\make.exe  CONFIG=Debug -j4" in directory "C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln" on local computer
1>C:/SysGCC/arm-eabi/bin/arm-eabi-gcc.exe -ggdb -ffunction-sections -O0   -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -IC:/Users/nickm/AppData/Local/VisualGDB/EmbeddedBSPs/arm-eabi/com.sysprogs.arm.mbed/cmsis/TARGET_CORTEX_M -I..\..\TH218\Inc -I..\..\TH218\Drivers\CMSIS\Device\ST\STM32H7xx\Include -I..\..\TH218\Drivers\STM32H7xx_HAL_Driver\Inc -I..\..\TH218\Middlewares\ST\STM32_USB_Device_Library\Core\Inc -I..\..\TH218\Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Inc -I..\..\TH218\Drivers\STM32H7xx_HAL_Driver\Inc\Legacy -I..\..\TH218\Middlewares\Third_Party\FatFs\src -I. -DDEBUG=1 -Dflash_layout -DSTM32H753xx -DARM_MATH_CM7 -DSTM32H753BI  -c ../../TH218/Lefty/lcd.c -o Debug/lcd.o -MD -MF Debug/lcd.dep
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\lcd.c(2):
1>../../TH218/Lefty/lcd.c: In function 'initRa8877Pins':
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\bios.h(13,27): warning : initialization makes pointer from integer without a cast [-Wint-conversion]
1> #define LCD1_DEVICE_ADDR  (uint32_t)0x60000000
1>                           ^
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\lcd.c(65,37): note :  in expansion of macro 'LCD1_DEVICE_ADDR'
1>     uint16_t *pLcdRStatusWAddress = LCD1_DEVICE_ADDR;      // read status or write address
1>                                     ^~~~~~~~~~~~~~~~
1>../../TH218/Lefty/lcd.c: In function 'initRA8877':
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\bios.h(13,27): warning : initialization makes pointer from integer without a cast [-Wint-conversion]
1> #define LCD1_DEVICE_ADDR  (uint32_t)0x60000000
1>                           ^
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\lcd.c(84,37): note :  in expansion of macro 'LCD1_DEVICE_ADDR'
1>     uint16_t *pLcdRStatusWAddress = LCD1_DEVICE_ADDR;     // read status or write address
1>                                     ^~~~~~~~~~~~~~~~
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\bios.h(14,27): warning : initialization makes pointer from integer without a cast [-Wint-conversion]
1> #define LCD1_DEVICE_DATA  (uint32_t)0x60000001
1>                           ^
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\lcd.c(87,26): note :  in expansion of macro 'LCD1_DEVICE_DATA'
1>     uint16_t *pLcdData = LCD1_DEVICE_DATA;
1>                          ^~~~~~~~~~~~~~~~
1>C:/SysGCC/arm-eabi/bin/arm-eabi-g++.exe -o Debug/TH218_sln.elf -Wl,-gc-sections --specs=nano.specs --specs=nosys.specs -TC:/Users/nickm/AppData/Local/VisualGDB/EmbeddedBSPs/arm-eabi/com.sysprogs.arm.stm32/STM32H7xxxx/LinkerScripts/STM32H753BI_flash.lds  -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard   -Wl,--start-group Debug/bios.o Debug/lcd.o Debug/sdram.o Debug/Ra8876_Lite.o Debug/usb_device.o Debug/usbd_conf.o Debug/usbd_desc.o Debug/usbd_cdc_if.o Debug/stm32h7xx_it.o Debug/stm32h7xx_hal_msp.o Debug/stm32h7xx_hal_timebase_TIM.o Debug/main.o Debug/system_stm32h7xx.o Debug/stm32h7xx_hal.o Debug/stm32h7xx_hal_adc.o Debug/stm32h7xx_hal_adc_ex.o Debug/stm32h7xx_hal_rtc.o Debug/stm32h7xx_hal_rtc_ex.o Debug/stm32h7xx_hal_fdcan.o Debug/stm32h7xx_hal_rng.o Debug/stm32h7xx_ll_fmc.o Debug/stm32h7xx_hal_nand.o Debug/stm32h7xx_hal_spi.o Debug/stm32h7xx_hal_spi_ex.o Debug/stm32h7xx_hal_mdma.o Debug/stm32h7xx_ll_sdmmc.o Debug/stm32h7xx_hal_sd.o Debug/stm32h7xx_hal_sd_ex.o Debug/stm32h7xx_hal_hsem.o Debug/stm32h7xx_hal_cortex.o Debug/stm32h7xx_hal_cryp.o Debug/stm32h7xx_hal_cryp_ex.o Debug/stm32h7xx_hal_dma.o Debug/stm32h7xx_hal_dma_ex.o Debug/stm32h7xx_hal_i2c.o Debug/stm32h7xx_hal_i2c_ex.o Debug/usbd_core.o Debug/usbd_ctlreq.o Debug/usbd_ioreq.o Debug/usbd_cdc.o Debug/stm32h7xx_hal_spdifrx.o Debug/stm32h7xx_hal_uart.o Debug/stm32h7xx_hal_uart_ex.o Debug/stm32h7xx_hal_pwr.o Debug/stm32h7xx_hal_pwr_ex.o Debug/stm32h7xx_hal_sram.o Debug/stm32h7xx_hal_flash.o Debug/stm32h7xx_hal_flash_ex.o Debug/stm32h7xx_hal_gpio.o Debug/stm32h7xx_hal_hash.o Debug/stm32h7xx_hal_hash_ex.o Debug/stm32h7xx_hal_pcd.o Debug/stm32h7xx_hal_pcd_ex.o Debug/stm32h7xx_ll_usb.o Debug/stm32h7xx_hal_hrtim.o Debug/stm32h7xx_hal_rcc.o Debug/stm32h7xx_hal_rcc_ex.o Debug/stm32h7xx_hal_crc.o Debug/stm32h7xx_hal_crc_ex.o Debug/stm32h7xx_hal_eth.o Debug/stm32h7xx_hal_tim.o Debug/stm32h7xx_hal_tim_ex.o Debug/stm32h7xx_hal_sai.o Debug/stm32h7xx_hal_sai_ex.o Debug/stm32h7xx_hal_sdram.o Debug/stm32h7xx_hal_qspi.o Debug/startup_stm32h753xx.o Debug/bsp_driver_sdram.o Debug/sdram_diskio.o Debug/fatfs.o Debug/diskio.o Debug/ff.o Debug/ff_gen_drv.o Debug/syscall.o     -Wl,--end-group
1>Debug/lcd.o: In function `initRA8877':
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\lcd.c(95): error : undefined reference to `lcdRegDataWriten'
1>collect2.exe : error : ld returned 1 exit status
1>make: *** [Debug/TH218_sln.elf] Error 1
1>-------------------------------------------------------------
1>Command exited with code 2
1>Executable: C:\SysGCC\arm-eabi\bin\make.exe
1>Arguments:  CONFIG=Debug -j4
1>Directory: C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln
1>VisualGDB : error : Command-line action failed
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3073: The command ""C:\Program Files (x86)\Sysprogs\VisualGDB\\VisualGDB.exe" /build "C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\TH218_sln.vcxproj" "/solution:C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln.sln"  "/config:Debug" "/platform:Win32"" exited with code 1.
1>Done building project "TH218_sln.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The extra 'n' at the end of

lcdRegDataWriten

?

1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\lcd.c(95): error : undefined reference to `lcdRegDataWriten'

JW

T J
Lead

Yes, I renamed it for the forum, .. well spotted..

I added the Void but that didn't help.

inline void lcdRegDataWriten(char reg, char data) {
//        *(__IO uint16_t*)LCD1_DEVICE_ADDR = reg;         
//        *(__IO uint16_t*)LCD1_DEVICE_DATA = data;    
    *(__IO uint16_t*)0x60000000 = reg;         
    *(__IO uint16_t*)0x60000001 = data;    
} 

Okay so post the whole offending file which caused the output above, or post the file together with the output, so we have a complete view.

Also, try to add a line

#error "no compile"

just below the line

inline void lcdRegDataWriten(char reg, char data) {

JW

T J
Lead

thanks for the pointers @Community member,​ @Community member​ 

was this the output you expected ?

1>------ Build started: Project: TH218_sln, Configuration: Debug Win32 ------
1>VisualGDB: Run "C:\SysGCC\arm-eabi\bin\make.exe  CONFIG=Debug -j4" in directory "VS2018\TH218_sln\TH218_sln" on local computer
1>C:/SysGCC/arm-eabi/bin/arm-eabi-gcc.exe -ggdb -ffunction-sections -O0   -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -IC:/Users/nickm/AppData/Local/VisualGDB/EmbeddedBSPs/arm-eabi/com.sysprogs.arm.mbed/cmsis/TARGET_CORTEX_M -I..\..\TH218\Inc -I..\..\TH218\Drivers\CMSIS\Device\ST\STM32H7xx\Include -I..\..\TH218\Drivers\STM32H7xx_HAL_Driver\Inc -I..\..\TH218\Middlewares\ST\STM32_USB_Device_Library\Core\Inc -I..\..\TH218\Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Inc -I..\..\TH218\Drivers\STM32H7xx_HAL_Driver\Inc\Legacy -I..\..\TH218\Middlewares\Third_Party\FatFs\src -I. -DDEBUG=1 -Dflash_layout -DSTM32H753xx -DARM_MATH_CM7 -DSTM32H753BI  -c ../../TH218/Lefty/lcd.c -o Debug/lcd.o -MD -MF Debug/lcd.dep
1>../../TH218/Lefty/lcd.c: In function 'lcdRegDataWriten':
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\lcd.c(16,2): error : #error "no compile"
1> #error "no compile"

and this is the current code:

inline void lcdRegDataWriten(char reg, char data) {
#error "no compile"
//        *(__IO uint16_t*)LCD1_DEVICE_ADDR = reg;         
//        *(__IO uint16_t*)LCD1_DEVICE_DATA = data;    
    *(__IO uint16_t*)0x60000000 = reg;         
    *(__IO uint16_t*)0x60000001 = data;    
} 

this is the usage:

    lcdRegDataWriten(1, 8);
 
 
with #error compile removed:
 
 
1>------ Build started: Project: TH218_sln, Configuration: Debug Win32 ------
1>VisualGDB: Run "C:\SysGCC\arm-eabi\bin\make.exe  CONFIG=Debug -j4" in directory "C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln" on local computer
1>C:/SysGCC/arm-eabi/bin/arm-eabi-gcc.exe -ggdb -ffunction-sections -O0   -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -IC:/Users/nickm/AppData/Local/VisualGDB/EmbeddedBSPs/arm-eabi/com.sysprogs.arm.mbed/cmsis/TARGET_CORTEX_M -I..\..\TH218\Inc -I..\..\TH218\Drivers\CMSIS\Device\ST\STM32H7xx\Include -I..\..\TH218\Drivers\STM32H7xx_HAL_Driver\Inc -I..\..\TH218\Middlewares\ST\STM32_USB_Device_Library\Core\Inc -I..\..\TH218\Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Inc -I..\..\TH218\Drivers\STM32H7xx_HAL_Driver\Inc\Legacy -I..\..\TH218\Middlewares\Third_Party\FatFs\src -I. -DDEBUG=1 -Dflash_layout -DSTM32H753xx -DARM_MATH_CM7 -DSTM32H753BI  -c ../../TH218/Lefty/lcd.c -o Debug/lcd.o -MD -MF Debug/lcd.dep
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\lcd.c(2):
1>../../TH218/Lefty/lcd.c: In function 'initRa8877Pins':
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\bios.h(13,27): warning : initialization makes pointer from integer without a cast [-Wint-conversion]
1> #define LCD1_DEVICE_ADDR  (uint32_t)0x60000000
1>                           ^
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\lcd.c(64,37): note :  in expansion of macro 'LCD1_DEVICE_ADDR'
1>     uint16_t *pLcdRStatusWAddress = LCD1_DEVICE_ADDR;      // read status or write address
1>                                     ^~~~~~~~~~~~~~~~
1>../../TH218/Lefty/lcd.c: In function 'initRA8877':
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\bios.h(13,27): warning : initialization makes pointer from integer without a cast [-Wint-conversion]
1> #define LCD1_DEVICE_ADDR  (uint32_t)0x60000000
1>                           ^
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\lcd.c(83,37): note :  in expansion of macro 'LCD1_DEVICE_ADDR'
1>     uint16_t *pLcdRStatusWAddress = LCD1_DEVICE_ADDR;     // read status or write address
1>                                     ^~~~~~~~~~~~~~~~
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\bios.h(14,27): warning : initialization makes pointer from integer without a cast [-Wint-conversion]
1> #define LCD1_DEVICE_DATA  (uint32_t)0x60000001
1>                           ^
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\lcd.c(86,26): note :  in expansion of macro 'LCD1_DEVICE_DATA'
1>     uint16_t *pLcdData = LCD1_DEVICE_DATA;
1>                          ^~~~~~~~~~~~~~~~
1>C:/SysGCC/arm-eabi/bin/arm-eabi-g++.exe -o Debug/TH218_sln.elf -Wl,-gc-sections --specs=nano.specs --specs=nosys.specs -TC:/Users/nickm/AppData/Local/VisualGDB/EmbeddedBSPs/arm-eabi/com.sysprogs.arm.stm32/STM32H7xxxx/LinkerScripts/STM32H753BI_flash.lds  -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard   -Wl,--start-group Debug/bios.o Debug/lcd.o Debug/sdram.o Debug/Ra8876_Lite.o Debug/usb_device.o Debug/usbd_conf.o Debug/usbd_desc.o Debug/usbd_cdc_if.o Debug/stm32h7xx_it.o Debug/stm32h7xx_hal_msp.o Debug/stm32h7xx_hal_timebase_TIM.o Debug/main.o Debug/system_stm32h7xx.o Debug/stm32h7xx_hal.o Debug/stm32h7xx_hal_adc.o Debug/stm32h7xx_hal_adc_ex.o Debug/stm32h7xx_hal_rtc.o Debug/stm32h7xx_hal_rtc_ex.o Debug/stm32h7xx_hal_fdcan.o Debug/stm32h7xx_hal_rng.o Debug/stm32h7xx_ll_fmc.o Debug/stm32h7xx_hal_nand.o Debug/stm32h7xx_hal_spi.o Debug/stm32h7xx_hal_spi_ex.o Debug/stm32h7xx_hal_mdma.o Debug/stm32h7xx_ll_sdmmc.o Debug/stm32h7xx_hal_sd.o Debug/stm32h7xx_hal_sd_ex.o Debug/stm32h7xx_hal_hsem.o Debug/stm32h7xx_hal_cortex.o Debug/stm32h7xx_hal_cryp.o Debug/stm32h7xx_hal_cryp_ex.o Debug/stm32h7xx_hal_dma.o Debug/stm32h7xx_hal_dma_ex.o Debug/stm32h7xx_hal_i2c.o Debug/stm32h7xx_hal_i2c_ex.o Debug/usbd_core.o Debug/usbd_ctlreq.o Debug/usbd_ioreq.o Debug/usbd_cdc.o Debug/stm32h7xx_hal_spdifrx.o Debug/stm32h7xx_hal_uart.o Debug/stm32h7xx_hal_uart_ex.o Debug/stm32h7xx_hal_pwr.o Debug/stm32h7xx_hal_pwr_ex.o Debug/stm32h7xx_hal_sram.o Debug/stm32h7xx_hal_flash.o Debug/stm32h7xx_hal_flash_ex.o Debug/stm32h7xx_hal_gpio.o Debug/stm32h7xx_hal_hash.o Debug/stm32h7xx_hal_hash_ex.o Debug/stm32h7xx_hal_pcd.o Debug/stm32h7xx_hal_pcd_ex.o Debug/stm32h7xx_ll_usb.o Debug/stm32h7xx_hal_hrtim.o Debug/stm32h7xx_hal_rcc.o Debug/stm32h7xx_hal_rcc_ex.o Debug/stm32h7xx_hal_crc.o Debug/stm32h7xx_hal_crc_ex.o Debug/stm32h7xx_hal_eth.o Debug/stm32h7xx_hal_tim.o Debug/stm32h7xx_hal_tim_ex.o Debug/stm32h7xx_hal_sai.o Debug/stm32h7xx_hal_sai_ex.o Debug/stm32h7xx_hal_sdram.o Debug/stm32h7xx_hal_qspi.o Debug/startup_stm32h753xx.o Debug/bsp_driver_sdram.o Debug/sdram_diskio.o Debug/fatfs.o Debug/diskio.o Debug/ff.o Debug/ff_gen_drv.o Debug/syscall.o     -Wl,--end-group
1>Debug/lcd.o: In function `initRA8877':
1>C:\Users\nickm\Documents\VS2018\TH218_sln\TH218_sln\..\..\TH218\Lefty\lcd.c(94): error : undefined reference to `lcdRegDataWriten'
1>collect2.exe : error : ld returned 1 exit status
1>make: *** [Debug/TH218_sln.elf] Error 1

sorry for the delayed response

Post the sources, possibly reduced to a bare minimum which still compiles and produces the problem.

JW

T J
Lead

is this what you are after ?