Code:
'*******************************************************************************
'* Name : microSD_Test1
'* Author : Kostas
'* Notice :
'* :
'* Date :
'* Version : 1.0
'* Notes :
'* :
'*******************************************************************************
include "modedefs.bas"
include "fuses_18f26k22.bas"
DEFINE OSC 64
DEFINE HSER_RCSTA 90h 'Hser receive status init
DEFINE HSER_TXSTA 20h 'Hser transmit status init
DEFINE HSER_BAUD 9600 'Hser baud rate
DEFINE HSER_CLROERR 1 'Hser clear overflow automatically
'Variables
i var byte
k var byte
'Registers
INTCON= 0 'disable all interrupts
INTCON2= %10000000 'Disable all pull-up resistors
TRISA= %00000000
TRISB= %00000000
TRISC= %00010000
ADCON0= 0
ANSELA=0
ANSELB=0
ANSELC=0
include "SDFSHC32D2K.bas"
SDC_UseHardSPI = TRUE
goto Init
'ISR routine
Init:
PORTB= 0
PORTA= 0
PORTC= 0
FAT_FileName[0] = "N" : FAT_FileName[1] = "A" : FAT_FileName[2] = "M"
FAT_FileName[3] = "E" : FAT_FileName[4] = "S" : FAT_FileName[5] = " "
FAT_FileName[6] = " " : FAT_FileName[7] = " "
FAT_FileName[8] = "T" : FAT_FileName[9] = "X" : FAT_FileName[10]= "T"
hserout ["Init routine: OK!",13,10]
i= 0
PAUSE 100
' ---------Main Programm--------
Main:
hserout ["LoopCount= ",dec i," FAT_error= ",dec fat_error," SDC_status= ",_
dec SDC_status," SDC_response= ",dec SDC_response,13,10]
Gosub FSInit
pause 100
Gosub FSInit
i= i+1
hserout ["LoopCount= ",dec i," FAT_error= ",dec fat_error," SDC_status= ",_
dec SDC_status," SDC_response= ",dec SDC_response,13,10]
pause 100
Gosub FSInit
i= i+1
hserout ["LoopCount= ",dec i," FAT_error= ",dec fat_error," SDC_status= ",_
dec SDC_status," SDC_response= ",dec SDC_response,13,10]
FAT_FileName[0] = "N" : FAT_FileName[1] = "A" : FAT_FileName[2] = "M"
FAT_FileName[3] = "E" : FAT_FileName[4] = "S" : FAT_FileName[5] = " "
FAT_FileName[6] = " " : FAT_FileName[7] = " "
FAT_FileName[8] = "T" : FAT_FileName[9] = "X" : FAT_FileName[10]= "T"
FAT_mode = "r" ' Read mode
Gosub FSfopen
If (FAT_error != 0) Then
i= i+1
hserout ["LoopCount= ",dec i," FAT_error= ",dec fat_error," SDC_status= ",_
dec SDC_status," SDC_response= ",dec SDC_response,13,10]
endif
FAT_count = 1 ' Read 1 byte to buffer at a time
Gosub FSfread
i= i+1
hserout ["LoopCount= ",dec i," FAT_error= ",dec fat_error," SDC_status= ",_
dec SDC_status," SDC_response= ",dec SDC_response,13,10]
k=0
While (FAT_error = 0)
Hserout [FAT_dest[k]]
k=k+1
FAT_count = 1 ' Read 1 byte to buffer at a time
Gosub FSfread
Wend
i= i+1
goto Main
end
And i receive this message in the serial communicator programm:
Bookmarks