.RES-File and additional files

General discussion on Visual TFT Software.
Post Reply
Author
Message
leon
Posts: 27
Joined: 08 Mar 2013 15:03

.RES-File and additional files

#1 Post by leon » 06 Aug 2013 16:09

Hi,
I'm using Visual TFT with external resources (.RES-File) on mmc.
My program should be able to handle additional files (creating, writing etc.) on mmc-card using the "Mmc_FAT16"-library.

First results: the system hangs up when assigning a new file.
After changing the settings to internal resources, the file was created well done.

Is there anything to consider when "switching" from .RES-File to other files?

leon
Posts: 27
Joined: 08 Mar 2013 15:03

Re: .RES-File and additional files

#2 Post by leon » 07 Aug 2013 08:03

Hi,

System: EasyMxPROv7 - Stellaris ARM
Compiler: VISUAL TFT 3.7
mikroC PRO for ARM 3.3.5
Attached is a sample file.

here is a sample code without ext. resources and its working:

Code: Select all

#include "caa_forum_objects.h"
#include "caa_forum_resources.h"

//--------------------- User code ---------------------//
// MMC module connections
sbit Mmc_Chip_Select           at GPIO_PORTA_DATA7_bit;  // for writing to output pin always use latch
sbit Mmc_Chip_Select_Direction at GPIO_PORTA_DIR7_bit;
// eof MMC module connections

//----------------- End of User code ------------------//

// Event Handlers

void create_file() {
 
 const unsigned long SPI_400kHz = 400000;
 const unsigned long SPI_10MHz  = 4000000;
 
 char filename[] = "test10.txt";
 
 
  //--- set up SPI for MMC init (low speed)
  SPI0_Init_Advanced(SPI_400kHz,
                     _SPI_MASTER,
                     _SPI_8_BIT | _SPI_CLK_IDLE_HIGH | _SPI_SECOND_CLK_EDGE_TRANSITION,
                     &_GPIO_MODULE_SPI0_A245);

  Delay_ms(10);

  //--- init the FAT library
  if (!Mmc_Fat_Init()) {
    // reinitialize spi at higher speed
    SPI0_Init_Advanced(SPI_10MHz,
                       _SPI_MASTER,
                       _SPI_8_BIT | _SPI_CLK_IDLE_HIGH | _SPI_SECOND_CLK_EDGE_TRANSITION,
                       &_GPIO_MODULE_SPI0_A245);
  }


 
 Mmc_Fat_Set_File_Date(2011,1,12,11,9,0);   // Set file date & time info
 Mmc_Fat_Assign(&filename,0xA0);
 Mmc_Fat_Rewrite();                          // To clear file and start with new data
 
 
 DrawScreen(&screen2);
 
 
}
Next is the code with ext. resources (.RES-file), which is not working.
Note: the init of SPI and Mmc is done by VISUAL TFT in the "driver"-file.

Code: Select all

#include "caa_forum_objects.h"
#include "caa_forum_resources.h"

//--------------------- User code ---------------------//


//----------------- End of User code ------------------//

// Event Handlers

void create_file() {

 char filename[] = "test10.txt";

 Mmc_Fat_Set_File_Date(2011,1,12,11,9,0);   // Set file date & time info
 Mmc_Fat_Assign(&filename,0xA0);
 Mmc_Fat_Rewrite();                          // To clear file and start with new data

 
 DrawScreen(&screen2);
  
}
Attachments
VISUAL_TFT2.rar
(136.68 KiB) Downloaded 190 times

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: .RES-File and additional files

#3 Post by janko.kaljevic » 07 Aug 2013 17:00

Hello,

TFT_Get_Data function is design to provide fastest reading from the SD card.
This means that Sd card is dedicated for the External resources.

You can modify this function and use it for other purposes at lose some of the speed for external resources.

You can modify it in VTFT by clicking Settings->Resources.
In following windows use this code.

Global Declarations

Code: Select all

// Place your global declarations here
// MMC/SD Connections
sbit Mmc_Chip_Select_Direction at GPIO_PORTA_DIR7_bit;
sbit Mmc_Chip_Select           at GPIO_PORTA_DATA7_bit;
// end of MMC/SD
// TFT Get Data globals
unsigned long currentSector = -1, res_file_size;
char Ext_File_Handle;
// end of TFT Get Data
Init Code:

Code: Select all

void Init_Ext_Mem() {
const unsigned long SPI_400kHz = 400000;
const unsigned long SPI_10MHz  = 4000000;
  // Initialize SPI
  SPI0_Init_Advanced(SPI_400kHz,
                     _SPI_MASTER,
                     _SPI_8_BIT | _SPI_CLK_IDLE_HIGH | _SPI_SECOND_CLK_EDGE_TRANSITION,
                     &_GPIO_MODULE_SPI0_A245);
  Delay_ms(10);
  //--- init the FAT library
  if (!Mmc_Fat_Init()) {
    // reinitialize spi at higher speed
    SPI0_Init_Advanced(SPI_10MHz,
                       _SPI_MASTER,
                       _SPI_8_BIT | _SPI_CLK_IDLE_HIGH | _SPI_SECOND_CLK_EDGE_TRANSITION,
                       &_GPIO_MODULE_SPI0_A245);
    // Open resource file for read
    Ext_File_Handle = Mmc_Fat_Open("%FILE_NAME", 1, 0xA0);
//    Mmc_Fat_Reset(&res_file_size);
  }
}
Get Data Code:

Code: Select all

char* TFT_Get_Data(unsigned long offset, unsigned long count, unsigned long *num) {
unsigned long start_sector;
unsigned int pos;
char dummy;

  Mmc_Fat_Activate(Ext_File_Handle);
  pos = (unsigned long)offset%512;

  Mmc_Fat_Seek(offset);
  Mmc_Fat_Read(&dummy);

  if(count>512-pos)
    *num = 512-pos;
  else
    *num = count;

  return f16_sector.fSect+pos;
}
Also in attachent find your project with these modifications and test it on your system.

Best regards.
Attachments
caa_forum_Code.rar
(35.94 KiB) Downloaded 199 times

leon
Posts: 27
Joined: 08 Mar 2013 15:03

Re: .RES-File and additional files

#4 Post by leon » 08 Aug 2013 11:28

Hi janko,
thank you for your answer.
I tried the code and it works fine.

I tested it also on a screen with more than 40 buttons (Virtual Keyboard).
When this screen pops up, I can see, that the speed is really down.

But its working and that is the important point.

Thanks :wink:

Post Reply

Return to “Visual TFT General”