Discussion in "8051 Discussion Forum" started by    say2paul    Aug 18, 2008.
Wed May 20 2009, 03:00 am
#21
well post your code only then i can tell you if u are doing right or not..
Tue Jul 21 2009, 03:48 pm
#22
Hi,

When I compiled the code using Keil, it shows some problems:


Build target 'Target 1'
assembling STARTUP.A51...
compiling main.c...
linking...
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: GETC
MODULE: main.obj (MAIN)
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: _PUTC
MODULE: main.obj (MAIN)
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: GETC
MODULE: main.obj (MAIN)
ADDRESS: 0010H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: _PUTC
MODULE: main.obj (MAIN)
ADDRESS: 0015H
Program Size: data=10.0 xdata=0 code=25
"TQ4000" - 0 Error(s), 4 Warning(s).


I am not sure about this warnings.

Any help?
Wed Jul 22 2009, 02:26 am
#23
well linker is not able to find these symbols (or say routines in your case) in the code.

you have to define getc and putc functions. are you using standard library?

try to add stdio.h header and compile again.

its better if you can post your code, so it will be easy to help you.
 naushad like this.
Wed Jul 22 2009, 09:23 am
#24
Hi Ajay,

Yes, I already included stdio.h.
My source code is here.

I am using AT89C52. In project, I included the startup code also.

#include <REG52.H>
                   	//8052 sfr registers
#include <stdio.h>
                   	//string manipulation
#include "softuart.h"    				//include the header file

//This is an echo program using software uart
void main(){
     unsigned char x;
     while(1){
          x = getc();
          putc(x);
    }
}
Thu Jul 23 2009, 09:37 am
#25
Hi Ajay,
Any Idea about this messages? Is it a serious warning? May I proceed by ignoring this messages?!
Thu Jul 23 2009, 09:53 am
#26
Ok, Ajay Finally I got the answer.

Problem was, I didn't added the ASM code and header to the project. Now I added them, and got one more warning --
softuart.asm(98): warning A41: MISSING 'END' STATEMENT



I just added one more line at the end of the ASM code: END


Now it compiled fine without any warning. !!!


Thanks anyway for the hints.
Sun Aug 09 2009, 10:37 pm
#27
naushad can u tell me in detail what all u did to resolve the warning L1 and L2 ? and plz post the code.
Thu Aug 27 2009, 10:07 am
#28
Surely Ajay,
First up all sorry for the delay to reply. I was out of home town for one month.

Anyway, the warnings were due to my unconsciousness to programming.

These warning appeared, because I didn't added ASM code and header you gave(softuart.h). When I added both to project tree, copilation becaome ok, but with one warning:
softuart.asm(98): warning A41: MISSING 'END' STATEMENT
This is because of the missing 'END' command at the end of ASM code. I added that to the ASM code and compiled ok and now it is working fine.
Once more thank you for your support.
Thu Aug 27 2009, 10:12 am
#29
The modified ASM code is here:


?SU?PUTC SEGMENT CODE
?SU?GETC SEGMENT CODE

PUBLIC _putc
PUBLIC getc

txd_pin EQU     P1.2            ;Transmit on this pin
rxd_pin EQU     P1.1            ;Receive on this pin

;Formula to calculate the bit time delay constant
;This constant is calculated as: (((crystal/baud)/12) - 5) / 2
;crystal is the frequency of crystal in Hz
;baud is required baudrate
;Please try to keep baudrate below 9600
;to get best results :-)

BITTIM  EQU     21;             (((11059200/9600)/12) - 5) / 2

;--------------------------------------------
;To send data serially
;For C programs
;Protype definition:
;               void putc(unsigned char);
;Usage:
;               putc(data);
;Return:
;               This function returns nothing
;
;For Assembly Programs:
;
;Usage:
;       data to be send has to be moved to R7
;       for example:
;               mov R7,#'a'
;               lcall _putc
;--------------------------------------------
RSEG ?SU?PUTC
_putc:
        push ACC
        Push PSW
        mov a,r7
        CLR txd_pin                     ;Drop line for start bit
        MOV R0,#BITTIM          ;Wait full bit-time
        DJNZ R0,$                       ;For START bit
        MOV R1,#8                       ;Send 8 bits
putc1:
        RRC A                           ;Move next bit into carry
        MOV txd_pin,C           ;Write next bit
        MOV R0,#BITTIM          ;Wait full bit-time
        DJNZ R0,$                       ;For DATA bit
        DJNZ R1,putc1           ;write 8 bits
        SETB txd_pin            ;Set line high
        RRC A                           ;Restore ACC contents
        MOV R0,#BITTIM          ;Wait full bit-time
        DJNZ R0,$                       ;For STOP bit
        POP PSW
        pop ACC
        RET

;--------------------------------------------
;To receive data Serially
;If you want to use this routine in your
;C program then define function prototype
; as:
;       unsigned char getc(void);
;
;       Usage:
;               data = getc();
;       Return value:
;               Returns data received
;
;
;If you are using it in assembly program
;       Usage:
;               lcall getc
;       Return:
;               data received is stored in R7
;--------------------------------------------

RSEG ?SU?GETC
getc:  
        Push ACC
        Push PSW
        JB rxd_pin,$            ;Wait for start bit
        MOV R0,#BITTIM/2        ;Wait 1/2 bit-time
        DJNZ R0,$                       ;To sample in middle
        JB rxd_pin,getc         ;Insure valid
        MOV R1,#8                       ;Read 8 bits
getc1:
        MOV R0,#BITTIM          ;Wait full bit-time
        DJNZ R0,$                       ;For DATA bit
        MOV C,rxd_pin           ;Read bit
        RRC A                           ;Shift it into ACC
        DJNZ R1,getc1           ;read 8 bits
        mov r7,a
        POP PSW
        pop ACC
        RET                                     ;go home
	END



I put the last END command, which was missing in the code. No more modification I did.
Mon Aug 31 2009, 06:14 am
#30
is it a gud way to use MUX
 naushad like this.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

ArktiTic
Sun May 05 2024, 07:06 pm
CesslasyNear
Sun May 05 2024, 02:58 pm
chimichmedic1204
Sun May 05 2024, 11:06 am
Jamiegob
Sun May 05 2024, 10:11 am
Gregoryjed
Sun May 05 2024, 10:02 am
Mariocax
Sun May 05 2024, 08:51 am
WilliamErync
Sun May 05 2024, 02:35 am
Danielnof
Sat May 04 2024, 11:12 pm