Please can someone help. I have a custom board running a PIC18f4620 a GLCD KS108 and a 2 GIG card. All works great and I have no problems. When I set up the project And I choose external there are 3 windows Global declarations, Init Code, and Get Data Code. Now I have no clue what to put in these boxes. I had a look at the examplea and used the big GLCD code as I have typed in here.
Code: Select all
''Global declarations:
'-----------------------------------------------
' Place your global declarations here
' MMC/SD Connections
dim Mmc_Chip_Select as sbit at LATC2_bit
dim Mmc_Chip_Select_Direction as sbit at TRISC2_bit
' end of MMC/SD
' GLCD Get Data globals
dim Ext_Data_Buffer as byte[512]
dim currentSector as longint
dim res_file_size as longword
' end of GLCD Get Data
'Init Code
'----------------------------------------------
sub procedure Init_Ext_Mem()
' Place your code here
currentSector = -1
' Initialize SPI
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH)
Delay_ms(10)
' Initialize MMC
if (Mmc_Fat_Init() = 0) then
' Reinitialize SPI at higher speed
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH)
' Open resource file for read
Mmc_Fat_Assign("%"FILE_NAME", 0)
Mmc_Fat_Reset(res_file_size)
end if
end sub
'---------------------------------------------------------
'Get Data Code
sub function GLCD_Get_Data(dim offset as longword, dim count as word, dim byref num as word) as ^byte
' Place your code here
dim start_sector as longword
dim pos as word
start_sector = Mmc_Get_File_Write_Sector() + offset div 512
pos = longword(offset) mod 512
if(start_sector = currentSector+1) then
Mmc_Multi_Read_Sector(Ext_Data_Buffer)
currentSector = start_sector
else if(start_sector <> currentSector) then
if(currentSector <> -1) then
Mmc_Multi_Read_Stop()
end if
Mmc_Multi_Read_Start(start_sector)
Mmc_Multi_Read_Sector(Ext_Data_Buffer)
currentSector = start_sector
end if
end if
if(count>512-pos) then
num = 512-pos
else
num = count
end if
result = @Ext_Data_Buffer+pos
end sub
'------------------------------------------------------------
Also in get data code box the sub function is wrong there is a semi colon when it should be a colon when you compile the code it stops with that error.
Oh and I do copy the res file to the sd card.
I have attached project in zip file.
Thanks
Anton