Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ADC programing error (KEIL)

Status
Not open for further replies.

Gastonio

Newbie level 5
Joined
May 8, 2010
Messages
9
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,359
Hello, I am having problem with program written with KEIL: *** error 65: access violation at I:0x81 : no 'write' permission. Can't find sollution myself, please, could you help?
This program takes info from ADC and writes it to RAM (100 samples). These is also delay routine with a 10x10ms=100ms.

The ADC is AD573 and processor is 8051.

RAM equ 0000H
ADC_CONV equ 4000H
ADC_READ_HBE equ 8000H
ADC_READ_LBE equ 0C000H
ADC_NIN equ 100
TIMER_MULTIP equ 10

ORG 0000H
SJMP MAIN
ORG 0040H

MAIN: MOV R1, #ADC_NIN
WAIT1: MOV DPTR, #ADC_CONV
MOVX @DPTR, A

WAIT2: JNB P3.2, WAIT2

LCALL READ (Deleted this statement, new error occured)

READ: MOV DPTR, #ADC_READ_HBE
MOVX A, @DPTR
MOV DPTR, #RAM
MOV DPH, R2
MOV DPL, R3
MOVX @DPTR, A
INC DPTR
MOV R2, DPH
MOV R3, DPL

MOV DPTR, #ADC_READ_LBE
MOVX A, @DPTR
ANL A, #0C0H
MOV DPH, R2
MOV DPL, R3
MOVX @DPTR, A
INC DPTR
MOV R2, DPH
MOV R3, DPL

LCALL DELAY

WAIT3: DJNZ R1, WAIT1

RET

DELAY: MOV TMOD,#01
MOV R0,#TIMER_MULTIP

WAIT4: MOV TH0,#0D8H
MOV TL0,#0EFH

SETB TR0

FLAG: JNB TF0, FLAG

CLR TR0
CLR TF0
DJNZ R0, WAIT4
RET

END
 

Maybe you could just say if I had explained the problem correctly?
 

my dear friend

the first rule in programming is that the main program executes in a closed loop.
other functions will be called from the main program and after executing the same,it will go back to the closed loop.this is applicable to interrupts also. the difference is that the main program will not call (main program can call the isr's in a different way)
but the interrupts will make the main program to stop and the isr get executed and again return to the main program.

just redesign the code keeping the above in mind, you will solve the problem
also use the debugger in keil and execute the code in step by step method. keep an eye on SFR's you will understand where the problem is

still there's a problem, please come back , we are there to help you

regards


ml
 

Thank you very much good people!
I deleted the LCALL READ statement, and the program took all of the 100 samples.

I also added two more lines:

MOV DPTR, #ADC_READ_HBE
MOVX A, @DPTR
MOV DPTR, #RAM
MOV DPH, R2 (This one)
MOV DPL, R3 (And this one)
MOVX @DPTR, A
INC DPTR
MOV R2, DPH
MOV R3, DPL

Now address for further info will be different. Before I made this correction, the info was always written in the same place of the ram over and over again.

And I noticed that the main program never stops: it collects all 100 samples and starts again because of the RET statement. However, I can't figure out, how to call END statement when the job is done.

Maybe like that?

DJNZ R1, WAIT1

SJMP HERE ; in place of the RET

........

HERE:
END

After doing this, the error: "*** error 65: access violation at C:0x0087 : no 'execute/read' permission" occured.
 

hi

just make the sjmp statement like this

HERE : SJMP HERE

and try

regards

ml
 

Thank you, you mean like this? By doing so, my program freezes and I have to cancel it.

RAM equ 0000H
ADC_CONV equ 4000H
ADC_READ_HBE equ 8000H
ADC_READ_LBE equ 0C000H
ADC_NIN equ 100
TIMER_MULTIP equ 10

ORG 0000H
SJMP MAIN
ORG 0040H

MAIN: MOV R1, #ADC_NIN
WAIT1: MOV DPTR, #ADC_CONV
MOVX @DPTR, A

WAIT2: JNB P3.2, WAIT2

MOV DPTR, #ADC_READ_HBE
MOVX A, @DPTR
MOV DPTR, #RAM
MOV DPH, R2
MOV DPL, R3
MOVX @DPTR, A
INC DPTR
MOV R2, DPH
MOV R3, DPL

MOV DPTR, #ADC_READ_LBE
MOVX A, @DPTR
ANL A, #0C0H
MOV DPH, R2
MOV DPL, R3
MOVX @DPTR, A
INC DPTR
MOV R2, DPH
MOV R3, DPL

ACALL DELAY

DJNZ R1, WAIT1

HERE: SJMP HERE


DELAY: MOV TMOD,#01
MOV R0,#TIMER_MULTIP

WAIT3: MOV TH0,#0D8H
MOV TL0,#0EFH

SETB TR0

FLAG: JNB TF0, FLAG
CLR TR0
CLR TF0
DJNZ R0, WAIT3
RET

END

Added after 2 hours 50 minutes:

Thank you, Microlab, I understood! I used debugger to look, how the program executes all commands and noticed that after job is done it comes to SJMP HERE which makes jump again to HERE and prgram stops. I thought the program was frozen because I didn't see registers filled with info until I checked my program step by step.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top