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 This is code compiled with Keil C, but not working #include <AT89X51.H> xdata char Index _at_ 0x00; void Clear_DDRAM(char index); void main(void) { Clear_DDRAM(0x00); while(1); } void Clear_DDRAM(char index) { int a; for(a=0;a<65536;a++) { P3_4=0; //IOCS=0; P3_1=0; P3_0=0; P1_0=0; //Reset=0; Index=index; P3_4=1; //IOCS=1; Index=Index+a; } } The xdata has 64K address range. Here is my queation: How to series to write data(0x00) into next address(Star address at 0x00). The assembly code is "INC DPTR" so have any instruction like it in keil C.
Hi Everyone I post my assembler code and use a illustration says what it is meant to say and hope you can clearly understand my questions? Assembler code ;------------------------------ DDRAM_RESET: MOV DPTR,#0000H MOV R0,#00H MOV R1,#00H MOV A,#00H RESET1: ;reset from 0000h to FF00h CALL ZEROWR INC DPTR INC R0 CJNE R0,#00H,RESET1 INC R1 CJNE R1,#FFH,RESET1 RESET2: ;reset 00FFh more CALL ZEROWR INC DPTR INC R0 CJNE R0,#FFH,RESET2 RET ;--------------------------------------------ZEROWR: ;Write 00 to MEM(DDRAM) thru 1352 CLR P3.4 ;MEMCS#=0, CLR P3.1 CLR P3.0 CLR P1.0 ;Ereset=0; MOVX @DPTR,A SETB P3.4 ;MEMCS#=1 RET ;------------------------------------------ Illustration: The data(index)=0x00 __ |00|Index(Address 0) | Next address |__| V |00|Index(address 1) |__| . . . . __ |00|Index(Address 65534) | Next address |__| V |00|Index(address 65535) |__| The external of memory start address(Index)=0x00 The next address(Index+1)=0x01
My guess it char xdata *xPtr; xPtr = 0; *xPtr = 0;
Hsu, That's what my code does. Also, you should not be calling the variable that holds your data "index." Aside from the fact that you already have a variable called "Index" and this is confusing, the "index" variable isn't being used as an index. Just take a look at the code I posted, and see if it's not what you're doing. Also, you use a CLR operation on P3.1, P3.0, and P1.0 INSIDE your loop, but nothing ever sets these high. You should put these up at the start of DDRAM_RESET for efficiency.
Dear Jay Thanks for your suggest code that I've tried and modify for my application. It is OK.