This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

efficient memcpy in Cypress FX2

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


If this is correct, the memcpy figures could be MUCH better than the figures given in the benchmarks. Any input welcome.

Parents
  • Thanks guys.

    My mistake was in thinking that the autodat registers were in SFR space like the address registers. But they're in external, so can only be accessed by MOVX, via the 'one at a time' DPTRs. So, 9 cycles/byte when clocking the cpu at maximum rate gives me 1.33MBytes/sec.

    I can improve on that a BIT because I know I will always be transferring an even number of bytes, so:

    loop:
         MOVX A, @DPTR   ; from AUTODAT1   2..9
         INC DPS         ; switch AUTODATs 1
         MOVX @DPTR, A   ; to AUTODAT2     2..9
         INC DPS         ; switch AUTODATs 1
         MOVX A, @DPTR   ; from AUTODAT1   2..9
         INC DPS         ; switch AUTODATs 1
         MOVX @DPTR, A   ; to AUTODAT2     2..9
         INC DPS         ; switch AUTODATs 1
         DJNZ R7, loop   ; 3
    

    gives me 15 cycles for 2 bytes = 1.6MBytes/sec. I think thats the best we can do.

    Thanks again,

    Mark.

Reply
  • Thanks guys.

    My mistake was in thinking that the autodat registers were in SFR space like the address registers. But they're in external, so can only be accessed by MOVX, via the 'one at a time' DPTRs. So, 9 cycles/byte when clocking the cpu at maximum rate gives me 1.33MBytes/sec.

    I can improve on that a BIT because I know I will always be transferring an even number of bytes, so:

    loop:
         MOVX A, @DPTR   ; from AUTODAT1   2..9
         INC DPS         ; switch AUTODATs 1
         MOVX @DPTR, A   ; to AUTODAT2     2..9
         INC DPS         ; switch AUTODATs 1
         MOVX A, @DPTR   ; from AUTODAT1   2..9
         INC DPS         ; switch AUTODATs 1
         MOVX @DPTR, A   ; to AUTODAT2     2..9
         INC DPS         ; switch AUTODATs 1
         DJNZ R7, loop   ; 3
    

    gives me 15 cycles for 2 bytes = 1.6MBytes/sec. I think thats the best we can do.

    Thanks again,

    Mark.

Children
No data