هیچ خطایی وجود ندارد فقط برنامه در خط driveinit هنگ میکند تا حدود 10 تا 30 ثانیه زمان صرف شود درضمن توجه داشتید که ممکن است دستور lcd نتواند خطا را نشان دهد ولی پورت سریال دادهای قبلی حتی با ریست میکرو را نشان میدهد و استفاده از goto به این دلیل بود و اما کد تغییر یافته به توجه به کد شما
کد:
$regfile = "m32def.dat"
$crystal = 16000000
$baud = 9600
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , E = Portc.4 , Rs = Portc.5
Restartlbl:
Cursor Off
Const Cmmc_soft = 1
#if Cmmc_soft = 0
Portb = 0
' --------- íßÑ ÈäÏí ÓÎÊ ÇÝÒÇÑí ----------------------------------------
' Chip-Select ãÔÎÕ ßÑÏä Çíå
Config Pinb.4 = Output
Mmc_cs Alias Portb.4
Set Mmc_cs
'ãÔÎÕ ßÑÏä Çíå SS
Config Pinb.4 = Output
Spi_ss Alias Portb.4
Set Spi_ss
' íßÑ ÈäÏí SPI
Config Pind.6 = Output
Portd.6 = 1 'active Mmc Power
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = High , Phase = 1 , Clockrate = 4 , Noss = 1
Print "MICRO START"
Cls
Lcd "MICRO START"
Portd.6 = 0
Waitms 10
Portd.6 = 1
Spsr = 1
Waitms 10
Spiinit
Spiinit 'Úãá ÈÑÞÑÇÑí ÇÑÊÈÇØ
Print "Spiinit"
' --------- ÇÊãÇã ------------------------------------------
#else
' --------- íßÑ ÈäÏí äÑã ÇÝÒÇÑí --------------------------------------
Config Pinb.4 = Output
Mmc_cs Alias Portb.4
Set Mmc_cs
' MOSI MMC/SD
Config Pinb.5 = Output
Set Pinb.5
Mmc_portmosi Alias Portb
Bmmc_mosi Alias 5
' MISO MMC/SD
Config Pinb.6 = Input
Mmc_portmiso Alias Pinb
Bmmc_miso Alias 6
' SCK MMC/SD
Config Pinb.7 = Output
Set Pinb.7
Mmc_portsck Alias Portb
Bmmc_sck Alias 7
' --------- ÇÊãÇã ----------------------------------------
#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 100
Dim Gbdriveerror As Byte
Dim Gbdriveerrorreg As Byte
Dim Gbdrivestatusreg As Byte
Dim Gbdrivedebug As Byte
$lib "MMC.LIB"
$external _mmc
Dim E As String * 10
Cls
Print "DRIVEINIT"
Lcd "DRIVEINIT"
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Gbdriveerror = Driveinit() 'ÈÑÞÑÇÑí ÇÑÊÈÇØ ÈÇMMC
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
If Gbdriveerror <> 0 Then Goto Restartlbl
E = Str(gbdriveerror)
Print "<driveerror=no>" ; E
Lcd "<driveerror=no>" ; E
E = Str(gbdriveerror)
Gbdriveerror = Drivecheck() 'ÇãÊÍÇä ÈÑÞÑÑÇÑí ÇÑÊÈÇØ
If Gbdriveerror <> 0 Then Goto Restartlbl
Cls
E = Str(gbdriveerror)
Lcd "Drivecheck:" ; E
Print "Drivecheck:" ; E
Cls
Lcd "MMC Ready"
Print "MMC Ready"
End