External SD Card

General discussion on Visual GLCD Software.
Post Reply
Author
Message
antonadc
Posts: 277
Joined: 14 Dec 2012 10:15
Location: Pretoria South Africa

External SD Card

#1 Post by antonadc » 10 Mar 2016 12:26

Hi all
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
'------------------------------------------------------------
When I run my project I get a blank screen. Can someone please point me in the right direction as to where I am going wrong.

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
Attachments
work_projects2b.zip
(487.2 KiB) Downloaded 148 times

User avatar
biljana.nedeljkovic
mikroElektronika team
Posts: 1043
Joined: 30 Jun 2015 15:15

Re: External SD Card

#2 Post by biljana.nedeljkovic » 11 Mar 2016 16:25

Hello,

You can take a look at the example that uses external memory.
"C:\Users\Public\Documents\Mikroelektronika\Visual GLCD\Projects\Examples with Extern Memory"

You can open them and go to Project settings.

Best regards,
Biljana

antonadc
Posts: 277
Joined: 14 Dec 2012 10:15
Location: Pretoria South Africa

Re: External SD Card

#3 Post by antonadc » 14 Mar 2016 07:36

You can take a look at the example that uses external memory.
"C:\Users\Public\Documents\Mikroelektronika\Visual GLCD\Projects\Examples with Extern Memory"
Sorry there is no folder such as 'examples with extern memory'

Thanks

Anton

User avatar
biljana.nedeljkovic
mikroElektronika team
Posts: 1043
Joined: 30 Jun 2015 15:15

Re: External SD Card

#4 Post by biljana.nedeljkovic » 14 Mar 2016 11:11

Hello,

Please download the newest version of the software.
http://www.mikroe.com/visualglcd/

If there are no examples, then check the attachment.

Kind regards,
Biljana
Attachments
Examples with Extern Memory.rar
(285.34 KiB) Downloaded 149 times

Post Reply

Return to “Visual GLCD General”