USB to USB flash Drive File Copier


Closed Thread
Results 1 to 40 of 223

Hybrid View

  1. #1
    Join Date
    Mar 2010
    Posts
    40


    Did you find this post helpful? Yes | No

    Default

    dear mackrackit
    below is my code..it like stuck at some where please help..
    INCLUDE "modedefs.bas"

    @ __config _HS_OSC & _WDT_OFF & _LVP_OFF & _CP_OFF
    ;----------------------------------------------------------------
    DEFINE OSC 20
    DEFINE LCD_DREG PORTA 'LCD Data line
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTB 'RS bit
    DEFINE LCD_RSBIT 5
    DEFINE LCD_EREG PORTB 'E bit
    DEFINE LCD_EBIT 4
    DEFINE LCD_RWREG PORTB 'RW bit
    DEFINE LCD_RWBIT 6
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_CHARS 20
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
    ;---------------------------------------------------------------
    VinTXD VAR PORTC.7 'AD0 TXD VDIP2 connect RX
    VinRXD VAR PORTC.6 'AD1 RXD VDIP2 connect TX
    FlowIn VAR PORTC.0 'AD2 RTS
    T VAR PORTC.0 'push button
    D VAR PORTC.1 ' PUSH BUTTON FOR DISPLAY
    ;----------------------------------------------------------------
    X VAR BYTE SYSTEM
    Y VAR BYTE SYSTEM
    ;----------------------------------------------------------------
    ;----------------------------------------------------------------
    ; -- Working with 2D arrays ---

    Width CON 8 ; Number of bytes in a Row
    Length CON 10 ; Number of Rows in the array
    ;---------------------------------------------------------------------------
    ArraySize CON Width * Length ; Total size of the array
    MyArray VAR BYTE[ArraySize] ; The Array

    Idx VAR BYTE ; Index, points to 1D array locations
    Xidx VAR BYTE ; 2D column Index
    Yidx VAR BYTE ; 2D row Index
    ArrayData VAR BYTE ; holding register for array data

    ;----[Get a value from the 2D array]----------------------------------------
    Get2D:
    Idx=(Yidx*Width+Xidx) MIN (ArraySize-1) ; find Index, limit to ArraySize
    ArrayData = MyArray(Idx) ; retrieve value from the array
    RETURN

    ;----[Put a value in the 2D array]------------------------------------------
    Put2D:
    Idx=(Yidx*Width+Xidx) MIN (ArraySize-1) ; find Index, limit to ArraySize
    MyArray(Idx) = ArrayData ; store the value in the array
    RETURN

    ;----[Set entire array to 0's]----------------------------------------------
    Clear2D:
    FOR Idx = 0 TO ArraySize-1
    MyArray(Idx) = 0
    NEXT Idx
    RETURN

    ;----[Turn the Subroutines into Functions]----------------------------------
    ASM
    #Get2D macro X, Y
    MOVE?BB X, _Xidx ; copy users X value to Xidx
    MOVE?BB Y, _Yidx ; copy users Y value to Yidx
    L?CALL _Get2D ; call the Get subroutine
    endm ; value is returned in ArrayData
    #define Get2D(X, Y) #Get2D X, Y ; allows paretheses in macro
    ;-----------------------
    #Put2D macro X, Y ; value should be in ArrayData
    MOVE?BB X, _Xidx ; copy users X value to Xidx
    MOVE?BB Y, _Yidx ; copy users Y value to Yidx
    L?CALL _Put2D ; call the Put subroutine
    endm
    #define Put2D(X, Y) #Put2D X, Y ; allows paretheses in macro
    ;-----------------------
    #Clear2D macro
    L?CALL _Clear2D ; call the Clear subroutine
    endm
    #define Clear2D() #Clear2D
    ENDASM

    ;----------------------------------------------------------------
    ;a var BYTE[12]

    FILE1 VAR BYTE[12]
    FILE2 VAR BYTE[12]
    FILE3 VAR BYTE[12]
    ;X VAR BYTE


    CRET VAR BYTE
    CRET = $0D
    ;----------------------------------------------------------------
    StartDisk:
    pause 3000
    HIGH VinRXD

    SEROUT2 VinRXD,84,["ECS",13]
    LCDOUT $FE,1, "1"
    PAUSEUS 1000
    HIGH VinRXD
    PAUSEUS 1000
    SEROUT2 VinRXD,84,["IPA",13]
    LCDOUT $FE,1, "2"

    HIGH VinRXD
    PAUSEUS 1000
    SEROUT2 VinRXD,84,["A:",13]
    LCDOUT $FE,1, "3"

    HIGH VinRXD
    PAUSEUS 1000
    SEROUT2 VinRXD,84,["DIR",13]
    LCDOUT $FE,1, "4"

    PAUSEUS 1000
    ;------------------------------------------------------------
    WAIT1
    IF FLOWIN = 1 THEN WAIT1
    SERIN2 VinTXD,84,[WAIT(CRET),STR FILE1\12 \CRET]
    LCDOUT $FE,1, "5"
    @ Clear2D ; clear the array
    FOR Y = 0 TO Length-1 ; fill the array with data
    FOR X = 0 TO Width-1
    ArrayData =FILE1[X] ; value to put in array
    @ Put2D(X,Y)
    NEXT X
    NEXT Y

    ;--------------------------------------------------------------------------------
    PAUSE 1000
    FOR Y = 0 TO Length-1
    FOR X = 0 TO Width-1
    @ Get2D(X,Y)
    NEXT X
    LCDOUT $FE,1,ArrayData
    pause 500
    NEXT Y
    goto StartDisk

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    So you got the new version of PBP?

    Where did you get it?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Mar 2010
    Posts
    40


    Did you find this post helpful? Yes | No

    Default

    u use the 2.46version...
    the code i use it like stuck only can run until the code below then stop
    INCLUDE "modedefs.bas"

    @ __config _HS_OSC & _WDT_OFF & _LVP_OFF & _CP_OFF
    ;----------------------------------------------------------------
    DEFINE OSC 20
    DEFINE LCD_DREG PORTA 'LCD Data line
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTB 'RS bit
    DEFINE LCD_RSBIT 5
    DEFINE LCD_EREG PORTB 'E bit
    DEFINE LCD_EBIT 4
    DEFINE LCD_RWREG PORTB 'RW bit
    DEFINE LCD_RWBIT 6
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_CHARS 20
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
    ;---------------------------------------------------------------
    VinTXD VAR PORTC.7 'AD0 TXD VDIP2 connect RX
    VinRXD VAR PORTC.6 'AD1 RXD VDIP2 connect TX
    FlowIn VAR PORTC.0 'AD2 RTS
    T VAR PORTC.0 'push button
    D VAR PORTC.1 ' PUSH BUTTON FOR DISPLAY
    ;----------------------------------------------------------------
    X VAR BYTE SYSTEM
    Y VAR BYTE SYSTEM
    ;----------------------------------------------------------------
    ;----------------------------------------------------------------
    ; -- Working with 2D arrays ---

    Width CON 8 ; Number of bytes in a Row
    Length CON 10 ; Number of Rows in the array
    ;---------------------------------------------------------------------------
    ArraySize CON Width * Length ; Total size of the array
    MyArray VAR BYTE[ArraySize] ; The Array

    Idx VAR BYTE ; Index, points to 1D array locations
    Xidx VAR BYTE ; 2D column Index
    Yidx VAR BYTE ; 2D row Index
    ArrayData VAR BYTE ; holding register for array data

    ;----[Get a value from the 2D array]----------------------------------------
    Get2D:
    Idx=(Yidx*Width+Xidx) MIN (ArraySize-1) ; find Index, limit to ArraySize
    ArrayData = MyArray(Idx) ; retrieve value from the array
    RETURN

    ;----[Put a value in the 2D array]------------------------------------------
    Put2D:
    Idx=(Yidx*Width+Xidx) MIN (ArraySize-1) ; find Index, limit to ArraySize
    MyArray(Idx) = ArrayData ; store the value in the array
    RETURN

    ;----[Set entire array to 0's]----------------------------------------------
    Clear2D:
    FOR Idx = 0 TO ArraySize-1
    MyArray(Idx) = 0
    NEXT Idx
    RETURN

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Sorry, I have not used arrays like that.
    You may want to go here
    http://www.picbasic.co.uk/forum/showthread.php?t=12870
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Mar 2010
    Posts
    40


    Did you find this post helpful? Yes | No

    Default

    what array you using? can show it?

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I have shown it several times starting in post#8 of this thread.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Mar 2010
    Posts
    40


    Did you find this post helpful? Yes | No

    Default

    using this way of array...if i got 10 file..then need to copy the X1X2 until X120? this way of array i have try it..it simple and easy...if i dunno the pendrive have how many file?

Similar Threads

  1. USB CDC Communications for Dummies!
    By Squibcakes in forum USB
    Replies: 104
    Last Post: - 15th January 2014, 13:43
  2. How to drive the Vinculum VDIP1 in UART mode
    By BrianT in forum Code Examples
    Replies: 41
    Last Post: - 23rd May 2013, 12:34
  3. Simple USB Comms Problem
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th January 2010, 20:17
  4. USB-FTDI[UM232R] with PIC16f877a
    By bjox in forum USB
    Replies: 1
    Last Post: - 23rd February 2008, 22:40
  5. PICs and USB Flash Drives
    By The Master in forum USB
    Replies: 2
    Last Post: - 23rd October 2007, 10:23

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts