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.
We are considering the Cypress FX2. Ive seen several postings about using the dual data pointers on some 8051 devices, but they don't seem to offer much advantage when you have to waste valuable time executing instructions to toggle between the two. Curiously, there's not much I can see on exploiting the auto-increment feature of the DPTRs in some 8051 variants, and in the FX2 at least, they can both be used without having one of them 'hidden'. I need an efficient memcpy between the FX2's endpoint memory space, (treated as a FIFO), and an external location. Is this the best way? Only two instructions in the loop... Or have I missed something?
MOV AUTOPTRSET,#03;; enable, inc 1, not 2 MOV r7,#64 ;;count MOV AUTOPTR1L,#c0 MOV AUTOPTR1H,#e7 ;; e7c0=EP1OUT buffer MOV AUTOPTR2L,#00 MOV AUTOPTR2H,#40 ;; 4000=external loop: MOV XAUTODAT2,XAUTODAT1 DJNZ R7,loop
I think you need to access the XAUTODATx registers using data pointers. For example, for single data pointer, this would be...
loop: MOV DPTR,#XAUTODAT1 MOV A,@DPTR MOV DPTR,#XAUTODAT2 MOV @DPTR,A DJNZ R7,loop
MOV DPTR,#XAUTODAT1 INC DPS MOV DPTR,#XAUTODAT2 INC DPS loop: MOV A,@DPTR INC DPS MOV @DPTR,A INC DPS
The INC DPS takes the same time as MOV DPTR, #. So, in this case, using dual data pointers is NOT more efficient. Jon, you are mistaken. Yes, the time for the 2 operations above are the same, but with one dptr, you need to save the fetch value and load the store value before the store as well as doing the reverse before the load. Have a peek at my example regardless of whether it reflect this particular implementation of dual dptr or not. Erik
There are two different points here. Erik points out that when using a single data pointer, you need to store the (changing) value of the DPTR when you switch, and thus it's more expensive than the traditional dual DPTR implementation. I agree, but the original poster was talking about yet another pointer mechanism in this particular variant (which are in addition to the traditional dual DTPRs). Jon is talking about using the DPTRs to point to the FX2 AUTODAT registers. These values are constant, and do not need to be stored. The loop can use MOV immediate to load the DPTRs. The INC DPS takes the same time as MOV DPTR, #. According to the Cypress manual, MOV DPTR, #value takes 3 bytes and 3 instruction cycles. INC DPS takes two bytes and two instruction cycles, so pre-loading the DPTRs and using INC DPS would slightly faster for any but tiny blocks to be copied. The MOV-based code would be smaller, though, as the pre-load instructions are not needed.