lpcware

Fat

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by renan on Wed Jun 30 14:05:24 MST 2010
This code is part of the usb bootloader example for rdb1768:
// Generate File Allocation Table to save Flash space
    // First Two FAT entries are reserved
    Fat_RootDir[0]= 0xF8;
    Fat_RootDir[1]= 0xFF;
    Fat_RootDir[2]= 0xFF;
    /* Start cluster of a file is indicated by the Directory entry = 2 */
    m = 3;
    for ( n = 3;n < NO_OF_CLUSTERS+2;n+=2) {
        if( n == ((NO_OF_CLUSTERS+2)-1) )
        {
          next_cluster = 0xFFF;
        }
        else
        {
          next_cluster = n + 1;
        }
          [COLOR=Red]Fat_RootDir[m] = (BYTE)n & 0xFF;
          Fat_RootDir[m+1] = (((BYTE)next_cluster & 0xF) << 4) | ((BYTE)(n>>8)&0xF);
          Fat_RootDir[m+2] = (BYTE)(next_cluster >> 4) & 0xFF;
        m = m+3;[/COLOR]
    }


What's going on in the red part of the code?

Suppose that the FAT is the image attached. An example of how it is going to be the [COLOR=Black] [/COLOR][COLOR=Black]Fat_RootDir vector.

Renan
[/COLOR]

Outcomes