First of all thank you for all you replies.
With regard to you Demon:
*Yes, I use capital letters for the files.
*Yes, I have selected to use PBPL (get the message when it is compiled).
*Yes, I am using an PIC18 part (specific PIC18F26K80).
*And yes, I also found what the error codes represents and as you stated they aren't so much of a help.
With regards to mackrackit:
As you can see in the code below, i have specified your line directly after I include the SDFS file.
And i use a 2GB card and it is in FAT format (and that will be FAT16, according to Microsoft).
I have already established that all my IO works, but today I am gonna try to monitor the data that is send
to the SD card and what he will send back
Code:
'configuration bits
#CONFIG
CONFIG RETEN = ON ; Ultra low-power regulator is Enabled (Controlled by SRETEN bit)
CONFIG INTOSCSEL = HIGH ; LF-INTOSC in High-power mode during Sleep
CONFIG SOSCSEL = HIGH ; High Power SOSC circuit selected
CONFIG XINST = OFF ; Disabled
CONFIG FOSC = INTIO2 ; Internal RC oscillator
CONFIG PLLCFG = ON ; Enabled
CONFIG FCMEN = ON ; Enabled
CONFIG IESO = OFF ; Disabled
CONFIG PWRTEN = ON ; Enabled
CONFIG BOREN = SBORDIS ; Enabled in hardware, SBOREN disabled
CONFIG BORV = 3 ; 1.8V
CONFIG BORPWR = ZPBORMV ; ZPBORMV instead of BORMV is selected
CONFIG WDTEN = ON ; WDT controlled by SWDTEN bit setting
CONFIG WDTPS = 512 ; 1:512
;CONFIG CANMX = PORTB ; ECAN TX and RX pins are located on RB2 and RB3, respectively
;CONFIG MSSPMSK = MSK7 ; 7 Bit address masking mode
CONFIG MCLRE = ON ; MCLR Enabled, RE3 Disabled
CONFIG STVREN = ON ; Enabled
CONFIG BBSIZ = BB2K ; 2K word Boot Block size
CONFIG CP0 = OFF ; Disabled
CONFIG CP1 = OFF ; Disabled
CONFIG CP2 = OFF ; Disabled
CONFIG CP3 = OFF ; Disabled
CONFIG CPB = OFF ; Disabled
CONFIG CPD = OFF ; Disabled
CONFIG WRT0 = OFF ; Disabled
CONFIG WRT1 = OFF ; Disabled
CONFIG WRT2 = OFF ; Disabled
CONFIG WRT3 = OFF ; Disabled
CONFIG WRTC = OFF ; Disabled
CONFIG WRTB = OFF ; Disabled
CONFIG WRTD = OFF ; Disabled
CONFIG EBTR0 = OFF ; Disabled
CONFIG EBTR1 = OFF ; Disabled
CONFIG EBTR2 = OFF ; Disabled
CONFIG EBTR3 = OFF ; Disabled
CONFIG EBTRB = OFF ; Disabled
#ENDCONFIG
'alias PIC pins definition
OP1 var PORTC.1 'For JUMPER1
OP1_TRIS var TRISC.1
TX1 var PORTC.0
TX1_TRIS var TRISC.2
OP2 var PORTB.4
OP2_TRIS var TRISB.4
RX1 var PORTC.2
RX1_TRIS var TRISC.2
OP3 var PORTB.2 'For JUMPER2
OP3_TRIS var TRISB.2
TX2 var PORTB.3
TX2_TRIS var TRISB.3
OP4 var PORTB.0
OP4_TRIS var TRISB.0
RX2 var PORTB.1
RX2_TRIS var TRISB.1
OP5 var PORTA.3 'For JUMPER3
OP5_TRIS var TRISA.3
TX3 var PORTA.2
TX3_TRIS var TRISA.2
OP6 var PORTA.6
OP6_TRIS var TRISA.6
RX3 var PORTA.7
RX3_TRIS var TRISA.7
SHTDWN var PORTA.1 'Shutdown 3.3V regulator
SHTDWN_TRIS VAR TRISA.1
SD_WE var PORTC.6 'SD card Write Protect
SD_WE_TRIS var TRISC.6 'SD card Write Protect direction
SDI var PORTC.4 'SPI data in
SDI_TRIS var TRISC.4 'SPI data in direction
SCL var PORTC.3 'SPI clock
SCL_TRIS var TRISC.3 'SPI clock direction
SD_CS var PORTA.5 'SD card Chip Select
SD_CS_TRIS var TRISA.5 'SD card chip select direction
SD_CD var PORTC.7 'SD card Detect
SD_CD_TRIS var TRISC.7 'SD card detect direction
SDO var PORTC.5 'SPI data out
SDO_TRIS Var TRISC.5 'SPI data out direction
Rail_v var PORTA.0 'incomming 5V rail
Rail_v_TRis var TRISA.0
LED var PORTB.5 'Status LED
LED_TRIS var TRISB.5
MCLR var PORTE.3 'MCLR
PGD var PORTB.7 'PGD programming data
PGD_TRIS var TRISB.7
PGC var PORTB.6 'PGC programming clock
PGC_TRIS var TRISB.6
'includes:
include "SDFS.bas" ' include for using FAT16-SD card
'include "SDFShc32d.pbp."
SDC_UseHardSPI = FALSE
INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts
include "modedefs.bas"
'defines for compiler
DEFINE LOADER_USED 0 'Not using a bootloader
define OSC 16 'Tell PBP to expect 64MHz clock
'watchdog settings
WDTCON = 22 'Set WDT to 2 s (default = 2 s)
WDTCON.0 = 1 'enable watchdog
'oscillator settings
OSCCON = %01110000 'Set internal clock to 16 MHz
'OSCTUNE = %11000000 'enable PLL (clock = now 64 MHz)
'interrupt settings
INTCON = %00000000 'disabled all interupts
'option settings
'analog i/o port settings
ANCON0 = %00000001
ANCON1 = %00000000
SLRCON = %00000000
'digital i/o port settings
PADCFG1 = %00000000 'disable pull-up
WPUB = %00000000 'disable pull-up
ODCON = %00000000 'disable open-drain
TRISA = %00010101 'Port A
TRISB = %11001000 'Port B
TRISC = %11010001 'Port C
'adc settings
ADCON0 = %00000001
ADCON1 = %00110000 'Use internal 4.1 refference
ADCON2 = %10000000 'Right justified
'uart settings
'spi settings
'timer2
T2CON = %01111111 'postscaler=16,timer on, prescaler=16 (62500 Hz)
PR2 = 251 'comperator value is set to divide by 251(250 Hz)
PIR2.1 = 0 'reset flag
'constant definition
FIRMWARE_VERSION_M con 00 ' M + . + S is the firmware version -> XX.XX
FIRMWARE_VERSION_S con 10
log_control_max con 53 'Maxmimum data to be received from control board
log_pumpfix_max con 11 'and pumpfix board after logging reqeust
log_row_bytes con 67 'Add log_control and log_pumpfix + carriage return and 2 tabs
Startup_control_max con 1 'Maximu data to be received from control after start up request
log_general_max con 207 'Maximum of data that is contained in the general information block
log_info_banner con 229 'maximum of data that is contained in the infromation banner for the logging
log_ofset_bytes con 436 'Ofset in bytes for log data to be stored : log_general_max + log_info_banner
MAX_NOEN con 8000'max of log entries, after that a new file has to be created (~500 MB)
MAX_files con 3
File_PN_L con 10 'Following numbers represents the maximum number
File_SN_L con 9 'of bytes (LENGTH) that can be written to the
File_FV_L con 5 'file for each point in the general information
File_TSO_L con 6 'banner.
File_TSON_L con 6 'One byte represents one decimal value in a .txt
File_TT_L con 10 'file.
File_NOER_L con 9
File_NOEN_L con 4
File_PN_S con 15 'Following numbers represents the first (START)
File_SN_S con 43 'possistion (byte) of the corresponding general
File_FV_S con 72 'information.
File_TSO_S con 98 'All the given numbers are measured from the
File_TSON_S con 116 'starting point (0) in the file.
File_TT_S con 137
File_NOER_S con 167
File_NOEN_S con 197
'variable definition
TimerTick_max var word'variable to contain needed interval
TimerTick_counter var word'variable that counts the interval
LED_blink_counter var byte'variable for pulses on the error LED
i var byte
log_control_data var byte [log_control_max] 'array for received data
log_pumpfix_data var byte [log_pumpfix_max] 'array for received data
strtup_control_data var byte [Startup_control_max] 'array for recived data
AN0_value var word'variable to store ADC value of 5V rail
files_found var word'For indexing the number of files
File_PN var byte[File_PN_L] 'Variables to write to the
File_SN var byte[File_SN_L] 'SD card when there needs to
File_FV var byte[File_FV_L] 'be a new file to be
File_TSO var byte[File_TSO_L] 'generated
File_TSON var byte[File_TSON_L]
File_TT var byte[File_TT_L]
File_NOER var byte[File_NOER_L]
File_NOEN var byte[File_NOEN_L]
Current_TSO var long'Current values that are read out from the file
Current_TSON var long'on the SD card. These wil also be used for
Current_TT var long'general values to be written to the file
Current_NOER var LOng
Current_NOEN var word
Current_NOER_last var byte
'hardware initialisation
SHTDWN = 0
LED = 0
'software initialisation, setting variables at their initial value
TimerTick_max = 15000 'is 60 seconds
TimerTick_counter = 0 'Set counter to 0
LED_blink_counter = 0 'For indicating error
files_found = 0
Current_TSO = 0
Current_TSON = 0
Current_TT = 0
Current_NOER = 0
Current_NOEN = 0
pause 10000
'interrupt settings
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR2_INT, _TimerTick, PBP, yes
endm
INT_CREATE ;Creates the interrupt processor
ENDASM
@ INT_ENABLE TMR2_INT ;enable Timer 2 interrupts
'---[Main]----------------------------------------------------------------------
Main:
LED = 0 'indicate start up procedure
gosub FSInit 'initialise the SD card
Serout2 PORTB.1, 84, ["Init: ", FAT_error, " ", SDC_status, " ", SDC_response, $d, $a]
gosub SD_error_check 'Check for errors on SD card
gosub FINDfirst 'Look for files on SD card
While(FAT_error = 0) 'Find next file on card
files_found = files_found + 1
Gosub FINDnext
Wend
Bookmarks