Saturday, February 28, 2009

Fat32 complete library in asm language

Observing that the file system created by me is almost identical to FAT32, i decided to convert to FAT32, this library work with clusters from 256 bytes to 32768 bytes autodetect from storage device.

This library is in asm language.

This file system is designed for double buffered (a buffer to the Allocation Table and a data buffer) this method of using separate buffers increase the rate of transfer to the storage device.

The buffer’s separation between allocation table and the data, makes that at each change of the data cluster not to charge the next cluster index from storage device. In this case, the index is token from allocation table’s buffer, if this is inside the sector memorized inside buffer. If this is not inside the sector of the buffer, then will be saved the buffer in allocation table (in case that inside the buffer has been made a modification), and then will be loaded in the sector where the index is.

In this way can be made with the data buffer. The pointer can be putted at an particular offset from open file, and then, from the address of the pointer can be read byte with byte, the pointer been incremented automatically. The same will be the sectors inside the buffer, those will be changed automatically. It doesn’t matter for user which cluster or bit must be read, because everything is done automatically. User must set the address of the file needed and the pointer of the address of the byte inside the file.

Done functions:
-Go to file/folder ( address in clusters )
-Go to next file/folder in current directory ( this function return Flag T in Sreg = 0 if the pointer is on bottom of the list else return 1)
-Go to forward file folder in current directory ( this function return Flag T in Sreg = 0 if the pointer is on top of the list else return 1)
-Read address on pointed file/folder ( in clusters )
-Read short name of pointed file/folder ( string 11 char )
-Read full name of pointed file/folder ( string max 128 char )
-Read byte by byte the file opened ( offset of byte in file ) with autoincrement pointer
-Write byte by byte in the file opened ( offset of byte in file ) with autoincrement pointer ( this function work with append in file and have property to enlarge the size of file )
-Read pointed file size (in bytes)
-Write pointed file size = current pointer
-Read pointed file attribute
-Write pointed file attribute
-Read pointer in opened file
-Write pointer in opened file
-Create file with short name converted from long name( Creating with long name not completed )
-CloseFile ( when the file is closed if the pointer in file is bigger to actual size of file , the actual size of file = pointer position in file ( in read mode is not possible to point to an byte address bigger to file size but in write mode this is possible because the file is auto enlarged )

The terminal have next functions:
+ :
Go Down one file folder and read short and long file name.
- :
Go Up one file folder and read short and long file name.
Enter :
1) Go to selected folder,
2) Open selected file,
3) Close opened file.
Esc :
Close opened file
p :
Enter in write long file name, and Enter will convert from long filename to short filename
c :
Create file with converted short filename


Performance obtained with ATmega640 at 16 Mhz and SPI hardware at 8Mhz:

Write SD Card with 512 Bytes/cluster = 48659 Bytes/s
Write SD Card with 4096 Bytes/cluster = 40163 Bytes/s
Read SD Card with 512 Bytes/cluster = 70286 Bytes/s
Read SD Card with 4096 Bytes/cluster = 56229 Bytes/s

Transfer rate depends on the device storage and on fragmentation.
The flash used not include the terminal

Resources for maxim 512 bytes/cluster:
Flash= 3220 Bytes ( Only read section )
Flash= 5042 Bytes ( Read and write sections )
Ram for allocation table management= 542
Ram for data management= 629 (512Bytes (Data Buffer)+ 64 (Bytes String Long Name) + 11Bytes (String Short Name) + Variables )
Total Ram= 1171Bytes

Resources for maxim 4096 bytes/cluster:
Flash= 3220 Bytes ( Only read section )
Flash= 5042 Bytes ( Read and write sections )
Ram for allocation table management= 542
Ram for data management= 4213 (4096Bytes (Data Buffer)+ 64 Bytes (String Long Name) + 11Bytes (String Short Name) + Variables )
Total Ram= 4755 Bytes

The ram size is set by user because the maximum size of cluster is set by ram buffer data cluster

The data management library is a dynamic library ( That means this library can be open multiple times, and when you call the library in Z must be the beginning address of RAM to work with ) for this i wrote the ram size table occupied by allocation library and data management library separately

In conclusion we can work with multiple open files using a single library written in flash that can work with multiple sections of ram

Operating principle:
This block function is one example only for 512 Bytes/Cluster Fat32 formats for other cluster dimension the ram allocation is different.


Fig1


In this moment i work to create and allocation table library from static library to dynamic library

These two libraries ( allocation table and data section ) will be in 2 variants:
1) A library will have only buffer for data which can be put on the controllers with ram more than 655Bytes
2) A library that does not include buffers (will lose the stats of dynamic library) but which can be put on the controllers that have the minimum 128Bytes of ram
____________________________________________________________________

This library is concept to work with only one buffer and work fine to my MP3 players at 5Mhz with 320Kb/s melody with one artifice, and from this moment this library is open source
This library use 3016Bytes of flash and 655Bytes of ram memory
The up bloc description in Fig1 can by applied and for this library

1)Fat32_DataInit
2)Fat32_ReadByte
3)Fat32_GoToRoot
4)Fat32_GoToFile
5)Fat32_ResetDirPointer
6)Fat32_IncrementDirPointer
7)Fat32_DecrementDirPointer
8)Fat32_GetShortFileName
9)Fat32_GetLongFileName
10)Fat32_GetFileAdress
11)Fat32_ReadFileSize
12)Fat32_ReadFileAttr
13)Fat32_WritePointerInFile
14)Fat32_ReadPointerInFile
15)Fat32_OpenPointedFileFolder
16)Fat32_CloseFile

Last update 17-06-2009
Download fat32 read only library for atmega64
Download fat32 read only library for atmega8

Now this driver is updated and included in my ASM_SDK here

For support post a comment

Thursday, January 29, 2009

4x25W amplifier with internal usb control

This is a 4x22W amplifier 4Ohm which is young for a PCI Desktop slot and can be diagnosed and controlled by an internal USB connector.
This project is still in development stage
This card is made with a specialized circuit in Class D with I2C control interface produced by TexasInstruments TAS5414 QFP64 and a ATmega8 controller

Wednesday, January 14, 2009

USB Unipolar 3 in 1 Motor Stepper Controller

This is a usb controller for 3 engines unipolar step by step, you can move completely independent, and in terms of speed of rotation sense and the coordinated which should be.

The position of engine can take value between -2147483648 and 2147483647
Minim velocity = 0.015 steps/second
Maximum velocity = 1000 steps/second

Here i posted a brief presentation of the controller in the prototype phase, it will arrive in stores in a short period.

It is designed around an ATmega8 microcontroller with USB1.1 software interface and drivers that are used is ULN2003

This is the interface for the PC, to control in real-time the controller:








And this is the prototype controller board:


















In the next image is described command method :

From Digital electronics and programing

Update for PC program, add new function:


















Wednesday, November 12, 2008

3in1 unipolar motor steper controller

This project is designed for control 3 motors stepper independently with only one ATmega8 mocrocontroller

This project has been designed for unipolar engines

The interface is Serial 19200b/s

For Bipolar engines






















Download entire project

Wednesday, October 22, 2008

Real schematik to interface a SD/MMC card to atmega microcontrollers

Because many sites operate a scheme to connect an SD/MMC card to a ATmega microcontroller that is non functional, I mean scheme with dividing resistive to the ground, I decided to post an overall scheme real functional and will post and parameters operation of a card at different voltages, everything after more probe:

We know that most cards SD/MMC operates in a voltage between 2.7 and 3.6 V, I will recommend one to use the minimum operating voltage.
However such a card works at 5V supply voltage without any risk of failure, but a voltage across the card manufacturer's specifications will work only read data and read CID etc. Write delete functions will not work

SD/MMC card and ATmega at diferent voltages:





SD/MMC card and ATmega at same voltages:


Sunday, October 12, 2008

Spi Software for all atmega microcontrollers

This is a simple library for software SPI compatible with all ATmega microcontrollers according to specifications 45DB SPI interface

( is not tested yet )

Download ASM Library

Friday, October 10, 2008

Driver for Nand Flash memory chip for normal port operation

This is one driver for interfacing programs to Nand Flash Chip Memory as those used in Stik USB or SD / MMC cards

It is known that a page of a nand Flash memory is 2048 +16 Bytes

Nand flash memories allow delete only a block of data or the entire chip, writing a whole page, reading a whole page, or rewriting a page keeps unchanged, but you can not edit a byte already written a page.

This example is for 1GByte nand flash chip memory K9K8G08U0A

Download ASM code driver




























































Download .Max Orcad Project

PPC terminal for Com ports

This is one COM terminal for pocket PC for Windows Mobile 2003 or later

For running this terminal is necessary .Net Framework 2.0























Download .Exe Program

Smartphone terminal for Com ports

This is one sample com terminal for Windows mobile Smartphone edition 5.0 or later

For running this terminal is necessary .Net Framework 2.0























Download .Exe program

I2C library for 24C.... external EEprom memory for ATmega microcontrollers

This is a driver for control one 24c... EEProm memory on Byte level for read / write and page level for complete format

This driver is compatible with EEProm i2c memory between 512 and 65536 Bytes capacity.

This library is made for ATmega8 but with some modifications is working on all ATmega microcontrollers

Download this library

Wednesday, October 8, 2008

New explorer for max displays resolution 244x244

An explorer full display Samsung E700.
This driver will include:

  • 1) Draw a text:
- The default color set to initiate the page or run Explorer
- With a pre-color description in the order of drawing text

  • 2) Draws a link:
- Link will default colors to select and clear preset to initiate or start page Explorer, calling routines click on this link will call on the name and number to order the program.
- Link will set the colors in the description Linc to select and deselect preset to initiate or start page Explorer, calling routines click on this link will call on the name and number to order the program.
- Link will default to select colors and clear preset to initiate or start page Explorer, calling routines click on this link will call at the number and order of the program.
- Link will set the colors in the description Linc to select and deselect preset to initiate or start page Explorer, calling routines click on this link will call at the number and order of the program.

  • 3) text editor:
- During the translation page and display them when there is a text editor library will call the name of the program that is attached to the text and edit the command, the program can read the contents edited text of a buffer separate text content publisher to create page will be "FF", this program has to return the same string buffer that will be displayed in text editor.
- During the translation page and display them when there is a text editor library will be made by calling the program that is attached to the text and edit the command, the program can read the contents edited text of a buffer separate text content publisher to create page will be "FF", this program has to return the same string buffer that will be displayed in text editor.
(Color color text will be declared the creation of the page or initiate Explorer, the color of the border will be declared the creation of the color page or entering into Explorer, background color of text edit initially will be white)

  • 4) Chek box:
- During the translation page and display them when there is a check box library will call the name of the program that is attached in check box and the command, the program can read 2 = Neinitializat, 0 = We checked, 1 = ticked in the register R16 Thus creating the page will be read will be 2, this program has to return in the same register 0 = us option 1 = check, as will happen every call of that program and the routine question
- During the translation page and display them when there is a check box library will be made by calling the program that is attached in chek box and the command, the program can read 2 = Neinitializat, 0 = We checked, 1 = ticked in the register R16 Thus creating the page will be read will be 2, this program has to return in the same register 0 = us option 1 = check, as will happen every call of that program and the routine question

The format of description page in buffer is:

  • SetBacgroundColor:
- 4 | 0 | Color(Low),Color(High)

  • SetInkColor:
- 4 | 1 | Color(Low),Color(High)

  • SetBarColor:
- 4 | 2 | Color(Low),Color(High)

  • SetPointerAdress:
- 4 | 3 | X AdressForPointer,Y AdressForPointer

  • PrintStaticText:
- 4 + String length | 4 | 0 | LengthOfString | StringText
- 6 + String length | 4 | 1 | Low(InkColor),High(InkColor) | LengthOfString | StringText

  • PrintLinkText:
- 8 + String length Link+ String Length name of program | 5 | 0=Unselected,1=Selected | 0 | 0 | Number of char in Link | String in Link | Number of function in program | LengthOfStringNameProgram | StringNameOfProgram

- 12 + String length Link+ String Length name of program | 5 | 0=Unselected,1=Selected | 0 | 1 | Low(InkColorForUnSelected),High(InkColorForUnSelected) | Low(InkColorForSelected),High(InkColorForSelected) | Number of char in Link | String in Link | Number of function in program | LengthOfStringNameProgram | StringNameOfProgram

- 9 + String length Link | 5 | 0=Unselected,1=Selected | 1 | 0 | Number of char in Link | String in Link | Number of function in program | Low(AdressOfProgramToCall),High(AdressOfProgramToCall)

- 13 + String length Link | 5 | 0=Unselected,1=Selected | 1 | 1 | Low(InkColorForUnSelected),High(InkColorForUnSelected) | Low(InkColorForSelected),High(InkColorForSelected) Number of char in Link | String in Link | Number of function in program | Low(AdressOfProgramToCall),High(AdressOfProgramToCall)

  • PrintTextEdit:
- 8 + Max string length Text+ String Length name of program | 6 | 0=Unselected,1=Selected | 0 | Number of char in TextEdit | Max length of textEdit | String in TextEdit | NumberOfFunctionInProgram | LengthOfStringNameProgram |StringNameOfProgram

- 9 + Max string length Text | 6 | 0=Unselected,1=Selected | 1 | Number of char in TextEdit | Max length of textEdit | String in TextEdit | NumberOfFunctionInProgram | Low(AdressOfProgramToCall),High(AdressOfProgramToCall)

  • PrintKeckBox:
- 7 + String Length name of program | 7 | 0=Unselected,1=Selected | 0=UnCheked,1=Cheked | 0 | NumberOfFunctionInProgram | LengthOfStringNameProgram | StringNameOfProgram

- 8 | 7 | 0=Unselected,1=Selected | 0=UnCheked,1=Cheked | 1 | Low(Program name),High(Program name),Number | NumberOfFunctionInProgram

  • SetLinkColor:
- 6 | 8 | UnSelectedLinkColor(Low),UnSelectedLinkColor(High)| SelectedLinkColor(Low),SelectedLinkColor(High)

  • SetPointer:
- 4 | 9 | X Coordonate | Y Coordonate

  • PaintVerticalLine:
- 6 | 10 | 0 | X Coordonate | Y Coordonate | Y Length

- 8 | 10 | 1 | Low(Color),High(Color) | X Coordonate | Y Coordonate | Y Length

  • PaintHorizontalLine:
- 6 | 11 | 0 | X Coordonate | Y Coordonate | X Length

- 8 | 11 | 1 | Low(Color),High(Color) | X Coordonate | Y Coordonate | X Length

  • PaintSquare:
- 7 | 12 | 0 | X Coordonate | Y Coordonate | X Length | Y Length

- 9 | 12 | 1 | Low(Color),High(Color) | X Coordonate | Y Coordonate | X Length | Y
Length

  • SetPlotColor:
- 4 | 13 | Color(Low),Color(High)


Status = coming up soon

Topics toll programs by name and was implemented for the explorer to be compatible with Kernel V0.3 learned here

The stage of this explorer is:

For example for paint One label ,3 links , 1 versical bar, one horizontal bar, one rectangle , one check box ( uncheked) and one chek box (cheked) load in buffer memory this data code:

.Equ CodeForSetBacgroundColor = 0
.Equ CodeForSetInkColor = 1
.Equ CodeForSetBarColor = 2
.Equ CodeForSetPointerAdress = 3
.Equ CodeForPrintStaticText = 4
.Equ CodeForPrintLinkText = 5
.Equ CodeForPrintTextEdit = 6
.Equ CodeForPrintKeckBox = 7
.Equ CodeForSetLinkColor = 8
.Equ CodeForSetPointer = 9
.Equ CodeToPaintVerticalLine =10
.Equ CodeToPaintHorizontalLine =11
.Equ CodeToPaintSquare =12
.Equ CodeForSetPlotColor =13

.db 4,CodeForSetBacgroundColor,Low(BLUE),High(BLUE),
4,CodeForSetInkColor,Low(WHITE),High(WHITE),
6,CodeForSetLinkColor,Low(YELLOW),High(YELLOW),Low(RED),High(RED),
12,CodeForPrintStaticText,0,8,"Hello!!!",
4,CodeForSetPointer,0,8,
14,CodeForPrintStaticText,1,Low(RED),High(RED),8,"Hello!!!",
4,CodeForSetPointer,0,16,
24,CodeForPrintLinkText,0,0,0,8,"Hello!!!",1,8,"Hello!!!",
4,CodeForSetPointer,0,24,
24,CodeForPrintLinkText,1,0,0,8,"Hello!!!",1,8,"Hello!!!",
4,CodeForSetPointer,0,32,
24,CodeForPrintLinkText,0,0,0,8,"Hello!!!",1,8,"Hello!!!",
14,CodeForPrintKeckBox,0,0,0,8,"Hello!!!",
14,CodeForPrintKeckBox,0,1,0,8,"Hello!!!",
6,CodeToPaintVerticalLine,0,50,50,30,
6,CodeToPaintHorizontalLine,0,50,50,30,
7,CodeToPaintSquare,0,2,60,40,10,255

And result this for samsung e700 display:
























Text edit implemented
























This is the complete schematic for one atmega64 and one samsung e700 display( the ram memory is not necessarily )



























Monday, October 6, 2008

My third development board for ATmega640-1280-2560

There are modules and connectors to come on this development board.
Point out that I did not even cable.

Here is described the top face:





















Here is described Bottom face:






















Download .MAX project for orcad

Sunday, October 5, 2008

Manage page from SD/MMC/HDD memory with page bufer

This is one driver for accessing SD/MMC/HDD drive on byte level with auto replacement page selection

This driver support drives until up to the amount 2^41 in 512Bytes on page and 2^48 bytes in 65536Bytes per page

This library is ready to serves pages from 256 to 65536Bytes

Download ASM driver file


And this driver is interface to up driver and SD card memory


Download ASM driver file

With this drivers on ATmega640 at 19,5Mhz the transfer rate betwen Controller and SD card is :
-63167Bytes/s Linear write
-111550Bytes/s Linear read

Saturday, October 4, 2008