اطلاعیه

Collapse
No announcement yet.

If Gbdriveerror <> 0 Then End یعنی چی

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    If Gbdriveerror <> 0 Then End یعنی چی

    سلام بر اساتید
    این خط
    If Gbdriveerror &lt;&gt; 0 Then End

    وقتی میکرو به این خط میرسه هیچ عملی انجام نمیده (به خط های زیرین نمیره)

    کار این دستور چی هست مال mp3 پلیر با vs1003 هست
    این هم بقیه برنامه

    &#039;///////////////////////////////////////////////////////////////////////////////
    &#039;///////////////////////////////////////////////////////////////////////////////
    &#039;
    &#039; MP_3_PLAYER with VS1001k FOR MP3.FILES FORMAT Name 8.3 FAT16 AVR-DOS 5.5
    &#039; data 14-06-2007 versione BASCOM 1.8.11.3 AVR-DOS 5.5
    &#039; written by GIOVANNI DE LUCA
    &#039; HTTP://delucagiovanni.interfree.it robot applications and others
    &#039; HTTP://WWW.LNS.INFN.IT nuclear phisics applications
    &#039; HTTP://www.youtube.com/tubincolo my video mobile-robots
    &#039; deluca@lns.infn.it my e-mail
    &#039; to control it&#039;s used serial port com1 and pul &quot;UP&quot; to change songs
    &#039; to make test I used 64Mb MMC with 20 songs in the MMC
    &#039; but I thing that it&#039;s possible read bigger MMC memory without problem
    &#039;
    &#039;///////////////////////////////////////////////////////////////////////////////
    &#039;///////////////////////////////////////////////////////////////////////////////

    $prog &amp;HFF , &amp;H4F , &amp;HC5 , &amp;HFF &#039;FUSE BITS generated
    $regfile = &quot;M64def.dat &quot; &#039;IT&#039;S POSSIBLE USE DIFFERENT AVR-CHIPS
    $crystal = 14745600 &#039;BUT this NOT TESTED
    $baud = 115200

    $swstack = 256
    $hwstack = 256
    $framesize = 768
    &#039;-------------------------------------------------------------------------------
    Config Timer1 = Timer , Prescale = 64
    Config Clock = Soft
    Enable Interrupts
    Enable Timer1
    Enable Urxc &#039;abilita rs232
    On Timer1 Timer_1
    On Urxc Rs_232 &#039;salto per rs232
    Config Date = Dmy , Separator = .
    &#039;-------------------------------------------------------------------------------
    Avanti Alias Ping.0 &#039;tashih shavad
    Led Alias Portc.6 &#039;tshih shavad
    Vs_miso Alias Ping.1
    Vs_mosi Alias Portc.0
    Vs_clock Alias Portc.1
    Xcs Alias Portc.2
    Xreset Alias Portc.3
    Dreq Alias Pinc.4
    Bsync Alias Portc.5
    &#039;-------------------------------------------------------------------------------
    Config Avanti = Input &#039;pulsante avanti
    Config Led = Output &#039;led
    Config Vs_miso = Input &#039;serial input vs-1001
    Config Vs_mosi = Output &#039;serial out vs-1001
    Config Vs_clock = Output &#039;serial clock vs-1001
    Config Xcs = Output &#039;VS Chip Select
    Config Xreset = Output &#039;VS Reset
    Config Dreq = Input &#039;VS Data Request
    Config Bsync = Output &#039;VS Stream Request
    &#039;-------------------------------------------------------------------------------
    Declare Sub Vs_init()
    Declare Sub Soft_reset()
    Declare Sub Vs_write(byval Vs_address As Byte , Byval Data1 As Byte , Byval Data2 As Byte)
    Declare Function Vs_read(byval Vs_address As Byte) As Word
    Declare Sub Send_mp3(byval Filename As String)
    &#039;-------------------------------------------------------------------------------
    Const Vs_rd = &amp;B0000_0011 &#039;Write command vs1001
    Const Vs_wr = &amp;B0000_0010 &#039;Read command vs1001
    Const Vs_mode = 0
    Const Vs_status = 1
    Const Vs_clockf = 3
    Const Vs_decode_time = 4
    Const Vs_audata = 5
    Const Vs_volume = 11
    &#039;-------------------------------------------------------------------------------
    Config Lcdpin = Pin , Db4 = Pinf.4 , Db5 = Pinf.5 , Db6 = Pinf.6 , Db7 = Pinf.7 , E = Pinf.2 , Rs = Pinf.3
    Config Lcd = 16 * 2
    &#039;-------------------------------------------------------------------------------
    Dim B As Byte
    Dim I As Integer
    Dim J As Long
    Dim Curbyte As Long
    Dim S As String * 20
    Dim Sample_rate As Word
    Dim Bit_rate As Word
    Dim Is_stereo As Word
    Dim Audata As Word
    Dim Filename As String * 11
    Dim Mmc_data(512) As Byte &#039;512 byte
    Dim Tempo_new As Word
    Dim Tempo_old As Word
    Dim Flag_read As Bit
    Dim Flag_play As Bit
    Dim Comando As String * 10
    Dim Mode_low As Byte
    Dim Mode_hig As Byte
    Dim Volume As Word
    Dim Volume_low As Byte
    Dim Volume_hig As Byte
    &#039;-------------------------------------------------------------------------------

    &#039;Do
    &#039;Waitms 500
    &#039;Toggle Led
    &#039;Print &quot;Hi World...&quot;
    &#039;Print


    &#039;Loop

    Cls
    Lcd &quot;lcd is ok&quot;
    Wait 1
    Cls


    $include &quot;Config_AVR-DOS.BAS&quot;
    $include &quot;Config_MMC.bas&quot;

    B = Drivereset()
    B = Driveinit()

    $external Waitms &#039;include mmc

    If Gbdriveerror &lt;&gt; 0 Then End
    Lcd &quot;0&quot; &#039;include avr-dos
    B = Initfilesystem(1)
    Lcd &quot;1&quot; &#039;init file system
    If B &lt;&gt; 0 Then Print &quot;Errore MMC&quot; &#039;se errore
    Lcd &quot;2&quot;
    &#039;-------------------------------------------------------------------------------
    Bsync = 0
    Xreset = 0
    Xcs = 1
    Portg.0 = 1 &#039;res pull up
    Flag_play = 0 &#039;sta suonando ?
    Flag_read = 1 &#039;gia letto ?
    &#039;-------------------------------------------------------------------------------
    &#039;-------------------------- PROGRAM START -------------------------------------
    &#039;-------------------------------------------------------------------------------

    Print &quot;Dir *.mp3&quot; &#039;dir mp3
    Print
    &#039;-------------------------------------------------------------------------------
    &#039;---------------------- crea una lista dei brani mp3 presenti sulla MMC --------
    &#039;-------------------------------------------------------------------------------
    Open &quot;Lista.txt&quot; For Output As #9
    &#039;create file.list in MMC
    S = Dir( &quot;*.mp3&quot
    While Len(s) &gt; 0
    Print S ; &quot; &quot; ; Filedate() ; &quot; &quot; ; Filetime() ; &quot; &quot; ; Filelen()
    Print #9 , S &#039;memorizza la lista
    S = Dir()
    Wend
    Close #9
    &#039;-------------------------------------------------------------------------------
    Print &quot;VS1001 Init&quot;
    Vs_init &#039;reset hardware e inizializza
    &#039;-------------------------------------------------------------------------------
    &#039;--------------------------- MAIN PROGRAMM -------------------------------------
    &#039;-------------------------------------------------------------------------------
    Do
    Open &quot;Lista.txt&quot; For Input As #9 &#039;OPEN LA LISTA
    While Eof(#9) = 0
    Line Input #9 , S &#039;READ filename Mp3
    Call Send_mp3(s) &#039;play mp3
    Wend
    Close #9
    Loop
    End
    &#039;-------------------------------------------------------------------------------
    &#039;---------------------------- TIMER 1 ------------------------------------------
    &#039;-------------------------------------------------------------------------------
    Timer_1:
    If Bsync = 0 And Flag_play = 1 And Flag_read = 1 Then &#039;per leggere inforamzioni
    Flag_read = 0
    Audata = Vs_read(vs_audata)
    Sample_rate = Audata And &amp;H1E00
    Rotate Sample_rate , Right , 9
    Bit_rate = Audata And &amp;H1FF
    Is_stereo = Audata And &amp;H8000
    Rotate Is_stereo , Right , 15
    Print Sample_rate ; &quot;,&quot; ; Bit_rate ; &quot; Kbs,&quot; ; Is_stereo &#039;print informations
    End If

    If Bsync = 0 And Flag_play = 1 And Flag_read = 0 Then
    Tempo_new = Vs_read(vs_decode_time)
    If Tempo_new &lt;&gt; Tempo_old Then Print Tempo_new ; &quot; Sec&quot;
    Tempo_old = Tempo_new
    End If
    Return
    &#039;-------------------------------------------------------------------------------
    &#039;---------------------- RS 232 -------------------------------------------------
    &#039;-------------------------------------------------------------------------------
    Rs_232:
    Comando = Inkey()
    If Comando = &quot;1&quot; Then
    Mode_low.7 = 1 &#039;set to zero
    Bsync = 0
    Vs_write Vs_mode , &amp;H0 , Mode_low &#039;no loudness
    End If
    If Comando = &quot;2&quot; Then
    Mode_low.7 = 0 &#039;set to zero
    Bsync = 0
    Vs_write Vs_mode , &amp;H0 , Mode_low &#039;loudness
    End If
    If Comando = &quot;3&quot; Then
    Mode_low.1 = 0
    Bsync = 0
    Vs_write Vs_mode , &amp;H0 , Mode_low &#039;play normale
    End If
    If Comando = &quot;4&quot; Then
    Mode_low.1 = 1
    Bsync = 0
    Vs_write Vs_mode , &amp;H0 , Mode_low &#039;play veloce
    End If
    If Comando = &quot;5&quot; And Volume_low &lt; 250 Then
    Volume_hig = Volume_hig + 5
    Volume_low = Volume_low + 5
    Bsync = 0
    Vs_write Vs_volume , Volume_hig , Volume_low &#039;volume down
    End If
    If Comando = &quot;6&quot; And Volume_low &gt; 0 Then
    Volume_hig = Volume_hig - 5
    Volume_low = Volume_low - 5
    Bsync = 0
    Vs_write Vs_volume , Volume_hig , Volume_low &#039;volume up
    End If
    Comando = &quot;&quot;
    Return

    &#039;-------------------------------------------------------------------------------
    &#039;------------------------------ MP3 SUBROUTINES --------------------------------
    &#039;-------------------------------------------------------------------------------
    Function Vs_read(byval Vs_address As Byte) As Word
    Xcs = 0 &#039;Xcs low
    B = Vs_rd
    Shiftout Vs_mosi , Vs_clock , B , 1
    Shiftout Vs_mosi , Vs_clock , Vs_address , 1
    B = 0
    Shiftin Vs_miso , Vs_clock , B , 1
    Vs_read = B
    Shift Vs_read , Left , 8
    B = 0
    Shiftin Vs_miso , Vs_clock , B , 1
    Vs_read = Vs_read + B
    Xcs = 1 &#039;Xcs high
    End Function
    &#039;-------------------------------------------------------------------------------
    &#039;-------------------------------- WRITE ROUTINE --------------------------------
    &#039;-------------------------------------------------------------------------------
    Sub Vs_write(byval Vs_address As Byte , Byval Data1 As Byte , Byval Data2 As Byte)
    Xcs = 0
    B = Vs_wr
    Shiftout Vs_mosi , Vs_clock , B , 1
    Shiftout Vs_mosi , Vs_clock , Vs_address , 1
    Shiftout Vs_mosi , Vs_clock , Data1 , 1
    Shiftout Vs_mosi , Vs_clock , Data2 , 1
    Xcs = 1
    End Sub



    &#039;-------------------------------------------------------------------------------
    &#039;------------------------------- RESETTA E INIZILIZZA --------------------------
    &#039;-------------------------------------------------------------------------------
    Sub Vs_init()
    Xreset = 0
    Waitms 5
    Xreset = 1
    Waitms 10

    Do : Led = Dreq : Loop Until Dreq = 1
    Vs_write Vs_mode , &amp;H0 , &amp;H4 &#039;reset

    Do : Led = Dreq : Loop Until Dreq = 1
    Vs_write Vs_mode , &amp;H0 , &amp;H0

    Do : Led = Dreq : Loop Until Dreq = 1
    Mode_low.7 = 0 &#039;set to zero
    Vs_write Vs_mode , &amp;H4 , Mode_low &#039;bass

    Do : Led = Dreq : Loop Until Dreq = 1
    Vs_write Vs_mode , &amp;H4 , &amp;H40

    Do : Led = Dreq : Loop Until Dreq = 1
    Vs_write Vs_clockf , &amp;H9B , &amp;HE8 &#039;clockf 12.288 MHz VS1003

    Do : Led = Dreq : Loop Until Dreq = 1
    Vs_write Vs_volume , &amp;H00 , &amp;H00 &#039;volume =0 massimo

    End Sub
    &#039;-------------------------------------------------------------------------------
    &#039;--------------------------- SOFT RESET VS1001 ---------------------------------
    &#039;-------------------------------------------------------------------------------
    Sub Soft_reset
    Do : Led = Dreq : Loop Until Dreq = 1 &#039;wait Dreq
    Vs_write Vs_mode , &amp;H0 , &amp;H4 &#039;reset

    End Sub
    &#039;-------------------------------------------------------------------------------
    &#039;---------------------------- SEND FILE MP3 ------------------------------------
    &#039;-------------------------------------------------------------------------------
    Sub Send_mp3(byval Filename As String)
    Print &quot;Play : &quot; ; Filename
    Soft_reset &#039;resetta vs1001
    Flag_read = 1 &#039;per leggere una volta sample rate etc
    Flag_play = 0 &#039;inizia a leggere dopo che è stato letto il primo pacchetto

    Open Filename For Binary As #10 &#039;apri il file mp3 e play song

    Do : Led = Dreq : Loop Until Dreq = 1 &#039;wait Dreq

    While Eof(#10) = 0
    Get #10 , Mmc_data(1) , , 512 &#039;preleva 512 byte
    Do : Led = Dreq : Loop Until Dreq = 1 &#039;wait Dreq

    For I = 1 To 16
    For J = 1 To 32
    Bsync = 1
    Shiftout Vs_mosi , Vs_clock , Mmc_data(curbyte) , 1
    Bsync = 0
    Incr Curbyte
    Next J
    Do : Led = Dreq : Loop Until Dreq = 1 &#039;wait Dreq
    Next I &#039;first 32
    Curbyte = 1 &#039;after 16 16x32=512 byte
    If Avanti = 0 Then Goto Esci &#039;pulsante up
    Flag_play = 1 &#039;playing primo pacchetto
    Wend

    Esci:
    Flag_play = 0 &#039;stop play
    Close #10
    For I = 1 To 2048 &#039;send 2048 zeros to clear buffer
    B = 0
    Shiftout Vs_mosi , Vs_clock , B , 1 &#039;send 2048 byte
    Next I
    Print &quot;MP3 End&quot; &#039;end song

    Waitms 100 &#039;aspetta 100
    End Sub
    &#039;-------------------------------------------------------------------------------
    انجام پروژه هاي برنامه نويسي اندرويد
    [glow=red,2,300]نرم افزار نقشه هاي پاور کامپيوتر اندوريد[/glow]
    http://cafebazaar.ir/app/?id=com.atxdroid

    #2
    پاسخ : If Gbdriveerror &lt;&gt; 0 Then End یعنی چی

    mmc رو نمیتونه بشناسه.

    دیدگاه


      #3
      پاسخ : If Gbdriveerror &lt;&gt; 0 Then End یعنی چی

      اگه منظورت خود کد هست یعنی اگه متغیر (Gbdriveerror ) مخالف با 0 باشه به عبارتی برابر با 0 نباشه

      دیدگاه


        #4
        پاسخ : If Gbdriveerror &lt;&gt; 0 Then End یعنی چی

        شما توی بستن مدار MMC مشکل داری وقتی اشتباهی توی کار باشه این متغییر شماره ی ارور رو به شما برمیگردونه در نتیجه طبق این خط از برنامه اگر ارور داشته باشه روند برنامه متوقف میشه.
        الهم عجل لولیک الفرج

        فقط 313 نفر...

        دیدگاه


          #5
          پاسخ : If Gbdriveerror &lt;&gt; 0 Then End یعنی چی

          عجب :eek:

          من همین برنامه رو برای مگا 128 تا حالا استفاده میکردم و هیچ مشکلی نداشتم اما الان که میخام با مگا 64 کارکنم این ارور رو میده جالب این هست که توی مگا 128 در هرصورت ( نبود مموری قطع بودن سیم مموری ) حدود یک دقیقه صبر میکنه و بعد پیام 255 میده ولی با مگا 64 بدون هیچ وقفه ای(حدود یک ثانیه صبر میکنه ) مینویسه 255 من که گیج شدم جالب این هست که برنامه که اقای چیاکو ناصری کامپایل کردن برای مگا64 رو هم میزنم روی میکرو همین حالت رو داره و تا حالا شاید ده بار سیم کشی رو از پین میکرو تا سوکت mmc چک کردم از دوستان کسی تا حالا به این مشکل بر خورده؟؟
          انجام پروژه هاي برنامه نويسي اندرويد
          [glow=red,2,300]نرم افزار نقشه هاي پاور کامپيوتر اندوريد[/glow]
          http://cafebazaar.ir/app/?id=com.atxdroid

          دیدگاه


            #6
            پاسخ : If Gbdriveerror &lt;&gt; 0 Then End یعنی چی

            :eek:
            مشکل حل شد
            البته نه اینجوری :read:

            بلکه

            این طور معلومه وقتی که پایه مولتی متر رو میزاشتم روی پایه میکرو وصل میشد ه و وقتی برمیداشتم قطع میشه و این اخری ها اعصابم خورد شد و با هوا گرم داغش کردم شروع کرد مثل یه بچه میکرو کارکردن
            از همگی ممنون
            انجام پروژه هاي برنامه نويسي اندرويد
            [glow=red,2,300]نرم افزار نقشه هاي پاور کامپيوتر اندوريد[/glow]
            http://cafebazaar.ir/app/?id=com.atxdroid

            دیدگاه

            لطفا صبر کنید...
            X