We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi , I m working on 89c51Ic2. I have created a variable like as below
unsigned char xdata buffer1[256] ; unsigned char xdata buffer2[256]; void initBuffer(void) { unsigned char i=0; for(i=0;i<256;i++) { buffer1[i]=0; buffer2[i]=0; } } void printubuffer(void) { unsigned char i=0; for(i=0;i<256;i++) { uartSendchar(buffer1[i]); uartSendchar(' '); uartSendchar(buffer2[i]); } } void main() { initBuffer(); while(1) { printubuffer(); delay(1000); //delay in ms } }
note: in the above uartSendchar(char data) and delay(int) are working fine, so i dint added details about that. I have included all corresponding header files. Problem: >> For me buffer1 values is always showing with number from 0 to 255. its not printing always 0. buffer2 is showing 0.I got confused in this please help me to solve this issue >> I have used standard 8051 startup code please refer below startup code, please correct me if anything is wrong, i dont have clear knowledge about startup code, please help me
================================================= startup.A51 =============== $NOMOD51 ; User-defined <h> Power-On Initialization of Memory IDATALEN EQU 100H XDATASTART EQU 0 XDATALEN EQU 0x3FF PDATASTART EQU 0H PDATALEN EQU 0H ;</h> ;------------------------------------------------------------------------------ ; ;<h> Reentrant Stack Initialization IBPSTACK EQU 1 ; set to 1 if small reentrant is used. IBPSTACKTOP EQU 0xFF +1 ; default 0FFH+1 ; </h> PBPSTACK EQU 0 ; set to 1 if compact reentrant is used. PBPSTACKTOP EQU 0xFF +1 ; default 0FFH+1 ; </h> ;</h> XBPSTACK EQU 0 ; set to 1 if large reentrant is used. XBPSTACKTOP EQU 0xFFFF +1 ; default 0FFFFH+1 ; </h> ;------------------------------------------------------------------------------ PPAGEENABLE EQU 0 ; set to 1 if pdata object are used. PPAGE EQU 0 ; ; <o> SFR address which supplies uppermost address byte <0x0-0xFF> ; most 8051 variants use P2 as uppermost address byte PPAGE_SFR DATA 0A0H ; ; </e> ;------------------------------------------------------------------------------ ; Standard SFR Symbols ACC DATA 0E0H B DATA 0F0H SP DATA 81H DPL DATA 82H DPH DATA 83H NAME ?C_STARTUP ?C_C51STARTUP SEGMENT CODE ?STACK SEGMENT IDATA RSEG ?STACK DS 1 EXTRN CODE (?C_START) PUBLIC ?C_STARTUP CSEG AT 0 ?C_STARTUP: LJMP STARTUP1 RSEG ?C_C51STARTUP STARTUP1: IF IDATALEN <> 0 MOV R0,#IDATALEN - 1 CLR A IDATALOOP: MOV @R0,A DJNZ R0,IDATALOOP ENDIF IF XDATALEN <> 0 MOV DPTR,#XDATASTART MOV R7,#LOW (XDATALEN) IF (LOW (XDATALEN)) <> 0 MOV R6,#(HIGH (XDATALEN)) +1 ELSE MOV R6,#HIGH (XDATALEN) ENDIF CLR A XDATALOOP: MOVX @DPTR,A INC DPTR DJNZ R7,XDATALOOP DJNZ R6,XDATALOOP ENDIF IF PPAGEENABLE <> 0 MOV PPAGE_SFR,#PPAGE ENDIF IF PDATALEN <> 0 MOV R0,#LOW (PDATASTART) MOV R7,#LOW (PDATALEN) CLR A PDATALOOP: MOVX @R0,A INC R0 DJNZ R7,PDATALOOP ENDIF IF IBPSTACK <> 0 EXTRN DATA (?C_IBP) MOV ?C_IBP,#LOW IBPSTACKTOP ENDIF IF XBPSTACK <> 0 EXTRN DATA (?C_XBP) MOV ?C_XBP,#HIGH XBPSTACKTOP MOV ?C_XBP+1,#LOW XBPSTACKTOP ENDIF IF PBPSTACK <> 0 EXTRN DATA (?C_PBP) MOV ?C_PBP,#LOW PBPSTACKTOP ENDIF MOV SP,#?STACK-1 #if 0 ; Initialize bank mechanism to code bank 0 when using L51_BANK.A51 with Banking Mode 4. EXTRN CODE (?B_SWITCH0) CALL ?B_SWITCH0 ; init bank mechanism to code bank 0 #endif ;</h> LJMP ?C_START END =================================================
please help me, if anything wrong in startup.a51 please correct me, tool details: uvision4: V4.53.0.6 C51:v9.50a assembler: A51 8.02b BL51: v6.22 LIB51: v4.29
Good. Thanks for feedback.
Did you observe Erik's note about where (within startup.a51) that needs to be done...?