Hi-Tech c compiler

Jun 21, 2006 5 Replies

Hi its been ages since I brushed the dust of Hi-Tech compiler. Now I go to use it have a wee problem. Can MAKE OK. Paths and correct source file list are defined but when I go to COMPILE there are errors relating to:



extern void lcdinit(void);



lcdinit();



error 'undefined symbol' _lcdinit



Anyone advise what this could be - The error perhaps is caused by main looking for lcdinit rather than _lcdinit in the source below. However make works well so Im stimied Can anyone advise how to do a successful compile?


Here's my LCDINIT code:



psect text,class=CODE global _LCDINIT,_LCDCMD,_CHAROUT LCD_PORT EQU P0 ;4 bit interface/control



for Hitachi LCD (2 line) LCD_E EQU P2.7



R_MASK EQU 00000000B ;register access S_MASK EQU 00001000B ;DD/CG RAM access LOW_MASK EQU 11110000B ;mask out low nybble



CLS EQU 00000001B



D_SET EQU 00001000B ;display on/off control E_SET EQU 00000100B ;entry mode control F_SET EQU 00100000B ;function set



D_D_ON EQU 00000100B ;display on D_D_OFF EQU 00000000B ;display off D_C_ON EQU 00000010B ;cursor on D_C_OFF EQU 00000000B ;cursor off D_B_ON EQU 00000001B ;blink on (blinking solid



box) D_B_OFF EQU 00000000B ;blink off (solid



underscore)



E_S_NO EQU 00000000B ;entry mode--don't shift E_S_YES EQU 00000001B ;entry mode--shift



display E_C_INC EQU 00000010B ;cursor move right E_C_DEC EQU 00000000B ;cursor move left



F_8BIT EQU 00010000B ;8-bit interface F_4BIT EQU 00000000B ;4-bit interface (D7-D0) F_2LINE EQU 00001000B ;2-line display F_1LINE EQU 00000000B ;1-line display F_8FONT EQU 00000000B ;font for 5x8 matrix F_11FONT EQU 00000100B ;font for 5x11 matrix



CG_ADDR EQU 01000000B DD_ADDR EQU 10000000B



;initialize the LCD



_LCDINIT: MOV A,#67 ;pause for 15ms lcall LWAIT



MOV A,#(F_SET OR F_8BIT) ;set 8-bit mode lcall LCD_OUT ;send to LCD



MOV A,#18 ;pause for 4.1ms lcall LWAIT



MOV A,#(F_SET OR F_8BIT) ;set 8-bit mode lcall LCD_OUT ;send to LCD



MOV A,#1 ;pause for 100us lcall LWAIT



MOV A,#(F_SET OR F_8BIT) ;set 8-bit mode lcall LCD_OUT ;send to LCD



MOV A,#18 ;pause for 4.1ms lcall LWAIT



MOV A,#(F_SET OR F_4BIT) ;set 4-bit mode lcall LCD_OUT ;send to LCD lcall LWAIT_40U ;pause for 40us



MOV A,#(F_SET OR F_4BIT) ORL A,#(F_2LINE OR F_8FONT) lcall _LCDCMDA ;set 4-bit, 2-line,


5x8 font

MOV A,#(D_SET OR D_D_OFF) ORL A,#(D_C_OFF OR D_B_OFF) lcall _LCDCMDA ;display, cursor,



blink off



MOV A,#(D_SET OR D_D_ON) ORL A,#(D_C_ON OR D_B_OFF) lcall _LCDCMDA ;display, underscore



cursor on



MOV A,#(E_SET OR E_S_NO) ORL A,#E_C_INC lcall _LCDCMDA ;cursor moves right,



no shift



RET ;initialization complete ;transmit nybble to LCD LCD_OUT: MOV LCD_PORT,A ;set up data and RS lines SETB LCD_E ;toggle Enable pin CLR LCD_E RET ;send command in ACC to LCD _LCDCMD: MOV A,R5 _LCDCMDA: PUSH ACC ;store the byte ANL A,#LOW_MASK ;mask out low nybble ORL A,#R_MASK ;set RS=0 lcall LCD_OUT ;send high order nybble of



command POP ACC ;get low order nybble SWAP A ;move to high nybble ANL A,#LOW_MASK ;mask out low nybble ORL A,#R_MASK ;set RS=0 lcall LCD_OUT ;send low order nybble of



command lcall LWAIT ;100us_40U ;pause



for 40us RET


;send character in ACC to



LCD _CHAROUT: CLR A MOV A,R5 CJNE A,#8,_BS MOV A,#10000B SJMP _LCDCMDA _BS: PUSH ACC ;store the byte ANL A,#LOW_MASK ;mask out low nybble ORL A,#S_MASK ;set RS=1 lcall LCD_OUT ;send high order nybble of



char POP ACC ;get low order nybble MOV B,A PUSH ACC MOV A,B



SWAP A ;move to high nybble ANL A,#LOW_MASK ;mask out low nybble ORL A,#S_MASK ;set RS=1 lcall LCD_OUT ;send low order nibble of



char lcall LWAIT_40U ;pause for 40us POP ACC RET ;40 microsecond delay,



assumes 12MHz clock ;12MHz/(12clocks/instr)=1



machine cycle per microsecond LWAIT_40U: MOV R3,#20 ;20 DJNZ instr = 40us DJNZ R3,$ RET ; ACC*100us delay, assumes


12MHz clock LWAIT: MOV R3,#50 ;DJNZ instr = 100us DJNZ R3,$ DJNZ ACC,LWAIT RET END

Not sure, I assume you included it in the project. Thy the HiTech Forum if you do not get an answer here.

I do not use the Hi-Tech compiler, but my best guess would be that your function name may be case sensitive.

maybe something like this :

_lcdinit:

Look in the documentation on how to make an assembly language routine a callable 'C' function.

Jim

(-- clip clip --)

Please check from your link map, if you have _LCDINIT, but no _lcdinit. The C language has case-sensitive symbols, the two symbols above *are* different.

Tauno Voipio tauno voipio (at) iki fi

Or it could be that a specific declaration is needed,

ie it thinks lcdinit() is not the extern'd lcdinit() because there is a mismatch somewhere in the declaration and definition? Some compilers will assume you are returning an int unless you specifically declare/define return as void????

Just a thought...

Bo

Thanks for reminding me - thats how lazy I get after programming in Delphi for a few years! However, thats not the case I typed the example in lowercase, but in fact the void statement was in the correct case. Unless someone reports the fix, I will advise when/if I sort it. Thanks, Al.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required