اطلاعیه

Collapse
No announcement yet.

ارتباط MMC با AVR

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

    ارتباط MMC با AVR

    من یه درخواست داشتم .
    من میخوام یکی در رابطه با (config_mmc.bas و config_dos-avr.bas ) توضیح بده.
    که این دو فایل کارش چیه و چه جوری باید توی bascom اونارو استفاده کنیم و کمی توضیح در رابطه با (mmc.lib ) هم می خوام .
    کامپایلر من همش برای (config_mmc.bas) ارور میده.


    #2
    پاسخ : ارتباط MMC با AVR

    آقا با استفاده از کتابخونه fat نیازی به خوندن سکتور اینا نیست درضمن تو پرئتیوس ام میتونی شبیه سازیش کنی الان آدرس تاپیکش یادم نیست اما fat یه سرچ کنی پیدا میشه

    دیدگاه


      #3
      پاسخ : ارتباط MMC با AVR

      $regfile = "M64def.dat " 'IT'S POSSIBLE USE DIFFERENT AVR-CHIPS
      $crystal = 16000000 'or any
      $baud = 9600
      $swstack = 64
      $hwstack = 128
      $framesize = 128
      Config Clock = Soft
      Config Date = Dmy , Separator = .
      Enable Interrupts
      Time$ = "2033"
      Date$ = "16.04.08"
      Dim B As Byte
      Dim L As Byte
      Dim Ff As Byte
      Dim S As String * 20
      Dim Diskf As Long
      Dim Disks As Long
      Dim Acc As Long
      Cls
      Print "Initation..."
      $include "Config_AVR-DOS.BAS"
      $include "Config_MMC.bas" 'include mmc

      Ff = Drivereset()
      Ff = Driveinit()

      $external Waitms

      If Gbdriveerror <> 0 Then

      Print "Error Config"

      Print Gbdriveerror
      End
      End If

      'include avr-dos

      B = Initfilesystem(1) 'init file system
      If B <> 0 Then Print "Error MMC"
      '-------------------------------------------------------------------------------
      '------------------------ PROGRAM START ------------------------------
      '-------------------------------------------------------------------------------
      Do
      Wait 2 'you can type your calling subroutine and another code
      Gosub A 'for example
      Loop

      End


      A:
      Print "Now Create file"
      Ff = Freefile()
      Open "ALI.txt" For Binary As #ff
      Acc = Lof(#ff)
      Print "acc:" ; Acc
      Seek #ff , Acc
      Print #ff , ""
      Print #ff , Time$
      Print #ff , Date$
      Close #ff
      Print Time$
      Return
      این یه برنامه هست که یه فایل تکست باز میکنه و توش ساعت وتاریخ می نویسه
      علم چندانکه بیشتر خوانی چون عمل در تو نیست نادانی

      دیدگاه


        #4
        پاسخ : ارتباط MMC با AVR

        دستت درد نکنه از راهنمایت الان روش کار میکنم خدا کنه جواب بده .
        اگر به مشکلی بر خوردم بازم مزاحمت میشم.

        دیدگاه


          #5
          پاسخ : ارتباط MMC با AVR

          نوشته اصلی توسط HOSSIENMED
          دستت درد نکنه از راهنمایت الان روش کار میکنم خدا کنه جواب بده .
          اگر به مشکلی بر خوردم بازم مزاحمت میشم.
          در خدمتم ولی نیاز به زدن تاپیک نبود
          تو سایت یه سرچ بزنین همه چیز هست و نمی خواد چشم انتظار هم باشین
          علم چندانکه بیشتر خوانی چون عمل در تو نیست نادانی

          دیدگاه


            #6
            پاسخ : ارتباط MMC با AVR

            سلام .
            باز من مزاحم شدم... سوالم این بود که این دو فایل (config_dos-avr.bas , config_mmc.bas) رو هر چی میگردم پیدا نمی کنم. :cry2:
            می تونی درباره این دو فایل بیشتر توضیح بدی.

            دیدگاه


              #7
              پاسخ : ارتباط MMC با AVR

              این دو فایل در پوشه sample درون بسکام وجود داره
              اگر نبود :
              http://samantest.freehostia.com/upload/config-.dos-mmc.zip


              دیدگاه


                #8
                پاسخ : ارتباط MMC با AVR

                سلام
                در مورد ارتباط AVR و MMC کامپایلر بسکام همش برای (config_mmc.bas) ارور میده. آیا کتابخانه ای باید اضافه کنیم .
                باتشکر

                دیدگاه


                  #9
                  پاسخ : ارتباط MMC با AVR

                  نوشته اصلی توسط mohammad qc
                  سلام
                  در مورد ارتباط AVR و MMC کامپایلر بسکام همش برای (config_mmc.bas) ارور میده. آیا کتابخانه ای باید اضافه کنیم .
                  باتشکر
                  باید کنار سورس اصلی بزاریش
                  علم چندانکه بیشتر خوانی چون عمل در تو نیست نادانی

                  دیدگاه


                    #10
                    پاسخ : ارتباط MMC با AVR


                    با سلام و خشته نباشید
                    من مطالب مربوط به ارتباط mmcبه avr رو در مجله نویز خوندم و طبق اون با mmcارتباط بر قرار کردم واقعا به کارم اومد ممنون ولی موقع خوندن بلوک های mmc میکرو فقط میتونه 2 بلوک (1024بایت)رو بخونه و درموقع شروع بلوک سوم درون حلقه While Response <> 0 می مونه ،مموریم SD 64MB .
                    با مموریه 1G هم هنگ مکنه.
                    ممنون میشم کمکم کنید...
                    $regfile = "m8def.dat"
                    $crystal = 16000000
                    $hwstack = 64
                    $swstack = 64
                    $framesize = 64

                    'LCD
                    Config Lcdpin = Pin , Db4 = Pinc.2 , Db5 = Pinc.3 , Db6 = Pinc.4 , Db7 = _
                    Pinc.5 , E = Pinc.1 , Rs = Pinc.0
                    Config Lcd = 16 * 2
                    Cursor Off : Cls
                    Deflcdchar 0 , 32 , 32 , 31 , 31 , 31 , 31 , 31 , 32 'First #
                    Deflcdchar 1 , 32 , 32 , 18 , 26 , 30 , 26 , 18 , 32 'Play/Pause >|
                    Deflcdchar 2 , 32 , 32 , 2 , 6 , 14 , 6 , 2 , 32 'Back <<
                    Deflcdchar 3 , 32 , 32 , 8 , 12 , 14 , 12 , 8 , 32 'Forward >>
                    Deflcdchar 4 , 32 , 17 , 10 , 4 , 10 , 17 , 32 , 32
                    Deflcdchar 5 , 32 , 32 , 1 , 2 , 20 , 8 , 32 , 32
                    'PWM
                    Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Down , Prescale = 1

                    Deflcdchar Print , 32 , 32 , 1 , 2 , 20 , 8 , 32 , 32 ' replace ? with number (0-7)

                    'Variables
                    Dim Command As Byte , Response As Byte , Address As Long , T As Byte
                    Dim K As Byte , Writes As Byte , Repeat As Word , Reads(512) As Byte
                    Dim I As Byte , Response1 As Byte , Address1 As Long , Firstaddress As Long


                    Declare Sub Minit
                    Declare Sub Mfirstfile
                    Declare Sub Mread(byval Address As Long)

                    Waitms 300

                    Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , _
                    Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 0

                    Config Portb.0 = Output
                    Cs Alias Portb.0
                    Spiinit

                    '____________________________________________ ___________________________________
                    'Main Prog Start Here:
                    For I = 1 To 100
                    Pwm1a = 0
                    Waitms 1
                    Pwm1a = 64
                    Waitms 1
                    Next I

                    Cls : Lcd " Search Card..."
                    Wait 2
                    Call Minit
                    Address1 = 0
                    Call Mread(address1)
                    Xloop:
                    End
                    '____________________________________________ ___________________________________
                    Sub Minit
                    Cls
                    Set Cs
                    Command = &HFF
                    For K = 1 To 10
                    Spiout Command , 1
                    Next K
                    Response = &HFF
                    Reset Cs
                    Command = &H40
                    Spiout Command , 1
                    Address = 0
                    Spiout Address , 4
                    Command = &H95
                    Spiout Command , 1
                    While Response <> &H01
                    Spiin Response , 1
                    Wend
                    Locate 1 , 1 : Lcd Hex(response)
                    Response1 = Response
                    Set Cs
                    Waitms 50
                    Command = &HFF
                    While Response <> &H00
                    Set Cs
                    Spiout Command , 1
                    Spiout Command , 1
                    Reset Cs
                    Command = &H41
                    Spiout Command , 1
                    Address = 0
                    Spiout Address , 4
                    Command = &HFF
                    Spiout Command , 1
                    Spiout Command , 1
                    Spiin Response , 1
                    Wend
                    Locate 2 , 1 : Lcd Hex(response)
                    Wait 2
                    If Response1 = 1 And Response = 0 Then
                    Cls : Lcd "MMC Taid shod"
                    Locate 1 , 15
                    Lcd Chr(5)
                    Else
                    Cls : Lcd "MMC error"
                    Locate 1 , 15
                    Lcd Chr(4)
                    End If
                    Wait 2
                    Return
                    End Sub
                    ---------------------------------------
                    Sub Mread(byval Address As Long)
                    Do
                    cls :lcd address
                    Set Cs
                    Command = &HFF
                    Spiout Command , 1
                    Reset Cs
                    Command = &H51
                    Spiout Command , 1
                    Spiout Address , 4
                    Command = &HFF
                    Spiout Command , 1
                    Spiin Response , 1
                    While Response <> 0
                    Spiin Response , 1
                    Wend
                    Locate 1 , 10: Lcd 1
                    While Response <> &HFE
                    Spiin Response , 1
                    Wend
                    Locate 1 , 10: Lcd 1
                    For Repeat = 1 To 512
                    Spiin Response , 1
                    Reads(repeat) = Response
                    Next
                    Set Cs
                    Address = Address + 512
                    Wait 1
                    Loop
                    Return
                    End Sub

                    دیدگاه


                      #11
                      پاسخ : ارتباط MMC با AVR

                      وااااااااااااااااااااااا مشتی این روش مال سال 500 شمسی هیت نه الان
                      ولی اگه اسرار داری یه کد میزارم خیلی شلوغه ولی کارت رو راه میندازه

                      کد:
                      '-------------------------------------------------------------------------------
                      
                      $regfile = "M32def.dat"
                      $crystal = 16000000
                      $baud = 9600
                      
                      
                      '-------------------------- MMC Pin Configuration ------------------------------
                      ' Change this pin configuration if it is necessary in your project.
                      Config Portb = Output
                      Reset Portb.0
                      Reset Portb.1
                      Reset Portb.2
                      Reset Portb.3
                      Cs Alias Portb.4 : Config Pinb.4 = Output          'Connected to Pin No.1 Of MMC (CS)
                      Mosi Alias Portb.5 : Config Pinb.5 = Output         'Connected to Pin No.2 Of MMC (DataIn)
                      Clk Alias Portb.7 : Config Pinb.7 = Output         'Connected to Pin No.5 Of MMC (Clock)
                      Miso Alias Pinb.6 : Config Pinb.6 = Input
                      
                      
                      'Cs Alias Portb.4 : Config Pinb.4 = Output          'for mega 32
                      'Mosi Alias Portb.5 : Config Pinb.5 = Output         'Connected to Pin No.2 Of MMC (DataIn)
                      'Clk Alias Portb.7 : Config Pinb.7 = Output         'Connected to Pin No.5 Of MMC (Clock)
                      'Miso Alias Pinb.6 : Config Pinb.6 = Input
                      
                      
                      'Cs Alias Portb.2 : Config Pinb.2 = Output          'for mega 8
                      'Mosi Alias Portb.3 : Config Pinb.3 = Output         'Connected to Pin No.2 Of MMC (DataIn)
                      'Clk Alias Portb.4 : Config Pinb.4 = Output         'Connected to Pin No.5 Of MMC (Clock)
                      'Miso Alias Pinb.5 : Config Pinb.5 = Input
                      
                      
                      
                      
                      
                      'Cs Alias Portb.0 : Config Pinb.0 = Output          'Connected to Pin No.1 Of MMC (CS)
                      'Mosi Alias Portb.2 : Config Pinb.2 = Output         'Connected to Pin No.2 Of MMC (DataIn)
                      'Clk Alias Portb.1 : Config Pinb.1 = Output         'Connected to Pin No.5 Of MMC (Clock)
                      'Miso Alias Pinb.3 : Config Pinb.3 = Input
                      'Config Portb.1 = Output
                      'Reset Portb.1                           'Connected to Pin No.7 Of MMC (DataOut)
                      
                      '---------------------------- MMC Var. Define ----------------------------------
                      ' MMC function declarations and variables.
                      ' DONT TOUCH THIS PART!!!
                      
                      Declare Sub Mmc_init
                      Declare Sub Mmc_status
                      Declare Sub Mmc_singleread
                      Declare Sub Mmc_singlewrite
                      Declare Sub Mmc_printbuffer
                      
                      Dim Mmc_buffer(512) As Byte
                      Dim Sector_pointer As Word
                      Dim Free_counter As Word
                      Dim Sector_number As Long
                      Dim Addr As Long
                      Dim Mmc_dat As Byte
                      
                      Dim Mmc_resp As Byte
                      Dim Mmc_resp2 As Word
                      Dim Y As Byte
                      Dim I As Word
                      Dim V As Byte
                      Dim T As Byte
                      Dim S As String * 70
                      Dim D As String * 70
                      Dim Dd As String * 1
                      Dim Ss As String * 1
                      Dim Idx As Byte
                      Dim A As Byte
                      Const Msbl = 0 : Const Msbh = 1
                      Const Spidelay = 5
                      
                      Wait 1
                      
                      Mmc_init
                      
                      '----------------------- Your Functions Declarations ---------------------------
                      ' Write Your Functions Declarations Here:
                      
                      '-------------------------------------------------------------------------------
                      
                      '-------------------------------- M A I N --------------------------------------
                      
                      'Write Here Your Main Code :
                      'Example :
                      '$lib "MMC.LIB"
                      '$external _mmc
                      Dim My_counter As Integer
                      Dim In_char As String * 1
                      'Lets have a look at the file we created
                      
                      Print "Dir function demo"
                      
                      Goto Xx
                      
                      Input "pleaz insert the name and press inter" , S
                      
                      Print "------------------start for buffer--------------------------"
                      
                      Idx = Len(s)
                      Print "len(s) hast :" ; Idx
                      For A = 1 To Idx
                      Ss = Mid(s , A , 1)
                      Select Case Ss
                      Case "A" :
                            Mmc_buffer(a) = 0
                            Print "0"
                      
                      
                      Case "B":
                            Mmc_buffer(a) = 1
                            Print "1"
                      
                      Case "C":
                            Mmc_buffer(a) = 2
                            Print "2"
                      Case "D":
                      
                            Mmc_buffer(a) = 3
                            Print "3"
                      Case "E":
                      
                            Mmc_buffer(a) = 4
                            Print "4"
                      Case "F":
                      
                            Mmc_buffer(a) = 5
                            Print "5"
                      Case "G":
                      
                            Mmc_buffer(a) = 6
                            Print "6"
                      Case "H":
                      
                            Mmc_buffer(a) = 7
                            Print "7"
                      Case "I":
                      
                            Mmc_buffer(a) = 8
                            Print "8"
                      Case "J":
                      
                            Mmc_buffer(a) = 9
                            Print "9"
                      Case "K":
                      
                           Mmc_buffer(a) = 10
                      Case "L":
                      
                           Mmc_buffer(a) = 11
                      Case "M":
                      
                            Mmc_buffer(a) = 12
                      Case "N":
                      
                            Mmc_buffer(a) = 13
                      
                      Case "O":
                      
                            Mmc_buffer(a) = 14
                      
                      Case "P":
                      
                             Mmc_buffer(a) = 15
                      Case "Q":
                      
                              Mmc_buffer(a) = 16
                      Case "R":
                      
                      
                              Mmc_buffer(a) = 17
                      Case "S":
                      
                              Mmc_buffer(a) = 18
                      Case "T":                          ':
                      
                              Mmc_buffer(a) = 19
                      Case "U":
                      
                              Mmc_buffer(a) = 20
                      Case "V":
                      
                             Mmc_buffer(a) = 21
                      Case "W":
                      
                              Mmc_buffer(a) = 22
                      Case "X":
                      
                              Mmc_buffer(a) = 23
                      Case "Y":
                      
                              Mmc_buffer(a) = 24
                      Case "Z":
                      
                              Mmc_buffer(a) = 25
                              Print "z"
                      Case " ":
                      
                              Mmc_buffer(a) = 26
                              Print "space"
                      Case Else:
                      Print "----------------------------error----------------------"
                      Print Ss
                      
                      
                      
                      End Select
                      Next
                      
                      Print "---------------------CLEAR---------------------------------"
                      
                      For A = 31 To 50
                      
                      Mmc_buffer(a) = 100
                      Next
                      
                      
                      
                      Input "INTER NOUMBER THEN PRES INTER" , D
                      
                      Idx = Len(d)
                      Print "len(s) hast :" ; Idx
                      Idx = Idx + 51
                      V = 1
                      For A = 51 To Idx
                      
                      Dd = Mid(d , V , 1)
                      Mmc_buffer(a) = Dd
                      Incr V
                      Next
                      
                      
                      For A = 120 To 255
                      Mmc_buffer(a) = 80
                      Next
                      
                      
                      
                      
                      
                      
                      'Wait for a key press.
                      Print "--Press Any Key To Continue..." : In_char = Waitkey()
                      'Write MMC Buffer At Sector No.10 :
                      Sector_number = 1700 : Mmc_singlewrite
                      
                      
                      Xx:
                      'Wait for a key press.
                      'Print "--Press Any Key To Continue..." : In_char = Waitkey()
                      'Read Sector No.10 And Fill MMC_Buffer With It :
                      Sector_number = 1700 : Mmc_singleread
                      Incr Sector_number
                      'Wait for a key press.
                      'Print "--Press Any Key To Continue..." : In_char = Waitkey()
                      'Send MMC Buffer To Serial Port :
                      Mmc_printbuffer
                      
                      Goto Xx
                      
                      End
                      
                      '--------------------------------- E N D ---------------------------------------
                      
                      
                      '------------------------------- Functions -------------------------------------
                      '-------------------------------------------------------------------------------
                      ' Write your functions here :
                      
                      
                      '-------------------------------------------------------------------------------
                      '---------------------------- Initializing MMC ---------------------------------
                      Sub Mmc_init
                      
                      Print "--Start Initializing MMC ..."
                      Set Portb.0
                      Set Portb.1
                      Set Portb.2
                      Set Portb.3
                      Set Cs
                      Mmc_dat = &HFF
                      For Free_counter = 1 To 10
                        Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                      Next Free_counter
                      Mmc_resp = 255
                      
                      Print "--Command No.=0"
                      Reset Cs
                      '40 dar asl argooman ast
                      'yani bite aval 0(start)bit 2vom(1){safhey 473 va 474 ketab}va 6 bit cmd ast}
                      Cmd0:
                      Mmc_dat = &H40 : Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay    '8 bite avval
                         Addr = 0 : Shiftout Mosi , Clk , Addr , Msbl , 32 , Spidelay    '32 bit argooman
                      Mmc_dat = &H95 : Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay    'crc(tashkise khata)
                      While Mmc_resp <> &H01                   'mitoni inja beshmari bebini chand ta klock mizaneh
                        Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                      Wend
                      Print "--Command Response :" ; Hex(mmc_resp)
                      
                      Set Cs
                      Waitms 50
                      
                      Print "--Command No.=1"
                      Reset Cs
                      Mmc_dat = &HFF
                      Cmd1:
                      While Mmc_resp <> &H00
                        Set Cs
                        Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                        Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                      
                        Reset Cs
                        Mmc_dat = &H41 : Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                           Addr = 0 : Shiftout Mosi , Clk , Addr , Msbl , 32 , Spidelay
                        Mmc_dat = &HFF : Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                                Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                        Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                      Wend
                      Mmc_dat = &HFF
                      Set Cs
                      
                      Print "--Command Response :" ; Hex(mmc_resp)
                      Print ""
                      Mmc_status                         '***************************chek for status
                      Print "--Initialize Complete."
                      
                      
                      End Sub
                      '-------------------------- MMC Initializing END -------------------------------
                      
                      '-------------------------------------------------------------------------------
                      
                      '---------------------------- Read MMC Status ----------------------------------
                      Sub Mmc_status
                      
                      Cmd13:
                      Set Cs
                      Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                      Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                      
                      Reset Cs
                      Mmc_dat = &H4D : Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay    'mmc dat=4d yani 4 ro bi khial d=13
                      'ya dakhele dastore cmd 1=mishe 41 va to cmd 0 mishe 40(yooohooo)
                         Addr = 0 : Shiftout Mosi , Clk , Addr , Msbl , 32 , Spidelay
                      Mmc_dat = &HFF : Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                               Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                      Shiftin Miso , Clk , Mmc_resp2 , Msbl , 8 , Spidelay
                      Print "" : Print "--Status :" ; Hex(mmc_resp2)
                      Set Cs
                      
                      End Sub
                      '--------------------------- Read MMC Status END -------------------------------
                      
                      '-------------------------------------------------------------------------------
                      
                      '------------------------- MMC Read Single Sector ------------------------------
                      Sub Mmc_singleread
                      
                      Addr = Sector_number * 512
                      Print "----------------------------------"
                      Print "--Start Sector Reading ..."
                      Print "--Read Sector Address :" ; Addr
                      Print "--Command No.=17,(Read Single Block)"
                      
                      Set Cs
                      Mmc_dat = &HFF
                      Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                      Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                      
                      Cmd17:
                      Reset Cs
                      Mmc_dat = &H51 : Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                               Shiftout Mosi , Clk , Addr , Msbl , 32 , Spidelay
                      Mmc_dat = &HFF : Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                      
                      Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                      While Mmc_resp <> 0
                        Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                      Wend
                      Print "--Command Response :" ; Hex(mmc_resp) : Print ""
                      
                      While Mmc_resp <> &HFE
                        Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                      Wend
                      
                      For Sector_pointer = 1 To 512
                         Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                         Mmc_buffer(sector_pointer) = Mmc_resp
                      Next Sector_pointer
                      
                      Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                      Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                      
                      Set Cs
                      Mmc_status                         '***************************chek for status
                      Print "--Sector Reading Finished."
                      
                      End Sub
                      '----------------------- MMC Read Single Sector END ----------------------------
                      
                      '-------------------------------------------------------------------------------
                      
                      '------------------------ MMC Write Single Sector ------------------------------
                      Sub Mmc_singlewrite
                      
                      Addr = Sector_number * 512
                      
                      Print "--Start Sector Writing ..."
                      Print "--Write Sector Address :" ; Addr
                      Print "--Command No.=24(Write Single Block)"
                      
                      Set Cs
                      Mmc_dat = &HFF : Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                               Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                      
                      Cmd24:
                      Reset Cs
                      Mmc_dat = &H58 : Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                               Shiftout Mosi , Clk , Addr , Msbl , 32 , Spidelay
                      Mmc_dat = &HFF : Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                               Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                      
                      Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                      While Mmc_resp <> 0
                        Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                      Wend
                      Print "--Command Response :" ; Hex(mmc_resp) : Print ""
                      
                      Mmc_dat = &HFE : Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                        For Sector_pointer = 1 To 512
                         Mmc_dat = Mmc_buffer(sector_pointer)
                         Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                        Next Sector_pointer
                      
                      Mmc_dat = &HFF : Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                      Mmc_dat = &HFF : Shiftout Mosi , Clk , Mmc_dat , Msbl , 8 , Spidelay
                      
                      Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                      Y = Mmc_resp And &H0F
                      If Y = &H05 Then                      'if mmcrecp=5 shod data accept misheh jigar
                        Print "" : Print "--Data Accepted."
                      End If
                      
                      Waitms 10
                      
                      Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                      If Mmc_resp = 0 Then Print "--MMC Is Busy!"
                      While Mmc_resp = 0
                        Shiftin Miso , Clk , Mmc_resp , Msbl , 8 , Spidelay
                      Wend
                      Print "--MMC Is Ready!"
                      
                      Set Cs
                      Mmc_status
                      Print "--Sector Writing Finished."
                      
                      
                      End Sub
                      '----------------------- MMC Write Single Sector END ---------------------------
                      
                      '-------------------------------------------------------------------------------
                      
                      '---------------------------- MMC Print Buffer ---------------------------------
                      Sub Mmc_printbuffer
                      
                      Print "--Start Reading MMC Buffer ..."
                      
                      S = ""
                      T = 1
                         Print "--MEGGGGGGGGGGA CHIP ADIBAN"
                      
                        For Sector_pointer = 1 To 512
                      
                         'If Mmc_buffer(sector_pointer) < 30 Then
                      
                      
                      
                         'Ss = Lookupstr(mmc_buffer(sector_pointer) , Sdata)
                         'Mid(s , T , 1) = Ss
                         'Print "  " ; S
                         'Print Mmc_buffer(sector_pointer)
                         'Incr T
                         'Else
                         Print Asc(mmc_buffer(sector_pointer)) ; ",";
                         'End If
                      
                      
                      
                         Free_counter = Sector_pointer Mod 16
                         If Free_counter = 0 Then Print ""
                        Next Sector_pointer
                      
                      
                      Print "--Reading MMC Buffer Finished."
                      
                      End Sub
                      '-------------------------- MMC Print Buffer END -------------------------------
                      '-------------------------------------------------------------------------------
                      '-------------------------------------------------------------------------------
                      
                      
                      
                      Sdata:
                      Data "A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" , "I" , "J" , "K" , "L" , "M" , _
                                  "N" , "O" , "P" , "Q" , "R" , "S" , "T" , "U" , "V" , "X" , "Y" , "Z" , " "
                      علم چندانکه بیشتر خوانی چون عمل در تو نیست نادانی

                      دیدگاه


                        #12
                        پاسخ : ارتباط MMC با AVR

                        خوب مشتی روش استفاده از mmc.libو avr dosرو که sram mega8 نمیکشه!!!
                        با روش mmc.libهم که هر کاری کردم جواب نداد بدون میکرو هم جواب minitالکی 0 میشد،فقط با spi سخت افزاری جواب گرفتم با این روش که اونم این مشکلو داشت،حالا تکلیف چیه؟!

                        دیدگاه


                          #13
                          پاسخ : ارتباط MMC با AVR

                          شرمنده میشه یه توضیح کلی در مورد این برنامه بدی؟
                          روش ارتباطش و چه کاری میکنه؟ممنون
                          HEEEELLLLLLLP ME :sad:

                          دیدگاه


                            #14
                            پاسخ : ارتباط MMC با AVR

                            به نظر خودت ارزش داره واسه 1000 تومن این قدر زجز بدی خودت رو؟؟؟ یه مگا16 بزار دیگه

                            به هر حال مد بالا با 8 هم هیچ مشکلی نداره.فقط باید زحمت بکشی یه کم کد رو سبک کنی.من با 8 اولین بار راه انداختم


                            دوست من این برنامه میتونه به روش سکتوری روی مموری بخونه و بنویسه واسه تحلیل مموری برنامه خوبیه اگر نه سر وفتش نیا
                            این ماله وقتیه که هنوز lib mmc نیومده بود و مجبور بودیم این جوری کار کنیم.حدود 5 سال پیش....... :cry2:
                            علم چندانکه بیشتر خوانی چون عمل در تو نیست نادانی

                            دیدگاه


                              #15
                              پاسخ : ارتباط MMC با AVR

                              امید جان ممنون که دست مارو گرفتی
                              من میخوام WAV PLAYER درست کنم،این WAVپلیرهای تو سایت ها هم هیچ کدوم بهم کار ندادن خوب حالا نظرت در مورد این برنامه چیه؟
                              ولی نمیدونم چرا آدرس Note padi که داخل مموری درست کردمو داخلش کلمه F1 رو نوشتم نمیتونه پیدا کنه!!؟
                              این مقدمه ایه فقط میخوام ببینم mmcرو درست میخونه!
                              حالا هرچی شما امر کنی آقا امید...

                              $regfile = "m8def.dat"
                              $crystal = 16000000

                              Config Lcdpin = Pin , Db4 = Pinc.2 , Db5 = Pinc.3 , Db6 = Pinc.4 , Db7 = _
                              Pinc.5 , E = Pinc.1 , Rs = Pinc.0
                              Config Lcd = 16 * 2
                              Cursor Off : Cls
                              Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Down , Prescale = 1

                              Const Cmmc_soft = 1


                              #if Cmmc_soft = 0

                              ' -------------------------------------------------


                              Config Pinb.0 = Output
                              Mmc_cs Alias Portb.0
                              Set Mmc_cs

                              Config Pinb.0 = Output
                              Spi_ss Alias Portb.0
                              Set Spi_ss



                              Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , _
                              Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 0

                              ' -------- ------------------------------------------

                              #else

                              ' --------------------------------------------


                              Config Pinb.0 = Output
                              Mmc_cs Alias Portb.0
                              Set Mmc_cs

                              Config Pinb.3 = Output
                              Set Pinb.3
                              Mmc_portmosi Alias Portb
                              Bmmc_mosi Alias 3

                              Config Pinb.4 = Input
                              Mmc_portmiso Alias Pinb
                              Bmmc_miso Alias 4


                              Config Pinb.5 = Output
                              Set Pinb.5
                              Mmc_portsck Alias Portb
                              Bmmc_sck Alias 5

                              ' ------------------------------------------------

                              #endif

                              ' =============================================


                              Const Cperrdrivereset = 225
                              Const Cperrdriveinit = 226
                              Const Cperrdrivereadcommand = 227
                              Const Cperrdrivewritecommand = 228
                              Const Cperrdrivereadresponse = 229
                              Const Cperrdrivewriteresponse = 230
                              Const Cperrdrive = 231
                              Const Cperrdrivenotsupported = 232

                              Waitms 1
                              Dim Gbdriveerror As Byte
                              Dim Gbdriveerrorreg As Byte
                              Dim Gbdrivestatusreg As Byte
                              Dim Gbdrivedebug As Byte
                              Dim A As Byte
                              Shoroo:
                              For A = 1 To 100
                              Pwm1a = 0
                              Waitms 1
                              Pwm1a = 64
                              Waitms 1
                              Next A
                              $lib "MMC.LIB"
                              $external _mmc
                              Cls
                              Do
                              Gbdriveerror = Driveinit()
                              Lcd Driveinit()
                              Gbdriveerror = Drivecheck()
                              Lowerline
                              Lcd Drivecheck()
                              Wait 2
                              If Driveinit() = 0 Then Exit Do
                              Locate 1 , 5 : Lcd "MMC error"
                              Loop
                              Cls : Lcd "MMC OK"
                              Wait 2


                              Dim Abuffer(512) As Byte
                              Dim Wsrampointer As Word
                              Dim Lsectornumber As Long
                              Dim I As Integer




                              Lsectornumber = 1

                              Do
                              Cls : Lcd Lsectornumber

                              Wsrampointer = Varptr(abuffer(1))

                              Gbdriveerror = Drivereadsector(wsrampointer , Lsectornumber)

                              For I = 1 To 512
                              Pwm1a = Abuffer(i)
                              Waitus 1
                              If Abuffer(i) = "1" And Abuffer(i -1) = "F" Then Exit Do
                              Next I
                              Incr Lsectornumber
                              Loop
                              Cls : Lcd "First File:" ; Lsectornumber
                              Lowerline
                              Lcd Abuffer(i)


                              End

                              دیدگاه

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