 
					
				
		
Hi,
I have written a small piece of code to copy the contents of paged flash memory into Ram.
const __far MemSegTable BL_AddressTable =
{
     { 0x00005000uL, 0x00006BFFuL },
     { 0x0000C000uL, 0x0000CFFFuL },
     { 0x00E08000uL, 0x00E0BFFFuL },
     { 0x00E18000uL, 0x00E1BFFFuL },
     { 0x00E28000uL, 0x00E2BFFFuL },
     { 0x00E38000uL, 0x00E3BFFFuL }
};
const __far uint32 BL_PtrToArray[6] =
{
    0xD18000,   /* Address of BL_Array_D1 */
    0xD28000,   /* Address of BL_Array_D2 */
    0xD38000,   /* Address of BL_Array_D3 */
    0xD48000,   /* Address of BL_Array_D4 */
    0xD58000,   /* Address of BL_Array_D5 */
    0xD68000    /* Address of BL_Array_D6 */
};
function( )
{
             flashAddress_t                 StartAddress;
             flashMemoryLength_t     PageLength;
             uint32                                 count;
             uint8 const __far *           pBootloaderArray;
             uint8 *                                 pRAMBuffer;
                         StartAddress          =  BL_AddressTable[NumOfBlks][0];
                         PageLength           =  ( BL_AddressTable[NumOfBlks][1] - BL_AddressTable[NumOfBlks][0] + 1 );
                         pBootloaderArray  =  ( uint8 const __far * )((const __far uint32)BL_PtrToArray[NumOfBlks]);
                         pRAMBuffer            =  RAMBuffer;
                         count                       =  0x100;
                         
                         while (count)
                         {
                                         (  * ( ( uint8 * ) pRAMBuffer ) )  =  (  * (  ( uint8 const __far *  ) ( pBootloaderArray ) ) );
                                         ( ( uint8 const __far *) ( pBootloaderArray ) )++;
                                         ( ( uint8 * ) pRAMBuffer )++;
                                         count--;
                         }
return();
}
I am getting the following error:
C1069: Wrong use of far/near/rom/uni/paged in local scope
Can anybody help me?
Solved! Go to Solution.
 
					
				
		
Hello
I would not recommend using far qualifier for anything else than a function or a pointer.
If you want to tell the compiler an object is allocated in paged memory you need to define it as follows:
#pragma CONST_SEG __GPAGE_SEG myPAGED_CONST
const __far uint32 BL_PtrToArray[6] =
{
    0xD18000,   /* Address of BL_Array_D1 */
    0xD28000,   /* Address of BL_Array_D2 */
    0xD38000,   /* Address of BL_Array_D3 */
    0xD48000,   /* Address of BL_Array_D4 */
    0xD58000,   /* Address of BL_Array_D5 */
    0xD68000    /* Address of BL_Array_D6 */
};
#pragma CONST_SEG DEFAULTAlso I would modify the initialization of pBootloadArray as follows:
pBootloaderArray = ( uint8 const __far * )(BL_PtrToArray[NumOfBlks]);
Please refer to TN238.pdf in {Install}\Help\PDF for more information on how to define variable, constants in paged memory.
CrasyCat
 
					
				
		
Sorry, the code is as written below.
uint8 RAMBuffer[0x100];
const __far uint32 BL_PtrToArray[6] =
{
    0xD18000,   /* Address of BL_Array_D1 */
    0xD28000,   /* Address of BL_Array_D2 */
    0xD38000,   /* Address of BL_Array_D3 */
    0xD48000,   /* Address of BL_Array_D4 */
    0xD58000,   /* Address of BL_Array_D5 */
    0xD68000    /* Address of BL_Array_D6 */
};
function( )
{
             uint32                                 count;
             uint8 const __far *           pBootloaderArray;
             uint8 *                                 pRAMBuffer;
                         pBootloaderArray  =  ( uint8 const __far * )((const __far uint32)BL_PtrToArray[NumOfBlks]);
                         pRAMBuffer            =  RAMBuffer;
                         count                       =  0x100;
                         
                         while (count)
                         {
                                         (  * ( ( uint8 * ) pRAMBuffer ) )  =  (  * (  ( uint8 const __far *  ) ( pBootloaderArray ) ) );
                                         ( ( uint8 const __far *) ( pBootloaderArray ) )++;
                                         ( ( uint8 * ) pRAMBuffer )++;
                                         count--;
                         }
return();
}
The error is on lines -
"uint8 const __far * pBootloaderArray;"
"pBootloaderArray = ( uint8 const __far * )((const __far uint32)BL_PtrToArray[NumOfBlks]);"
" ( * ( ( uint8 * ) pRAMBuffer ) ) = ( * ( ( uint8 const __far * ) ( pBootloaderArray ) ) ); "
Note: The aarray BL_PtrToArray[ ] is located in paged memory. The array RAMBuffer[ ] is in unpaged memeory.
Can anybody help me?
 
					
				
		
Hello
I would not recommend using far qualifier for anything else than a function or a pointer.
If you want to tell the compiler an object is allocated in paged memory you need to define it as follows:
#pragma CONST_SEG __GPAGE_SEG myPAGED_CONST
const __far uint32 BL_PtrToArray[6] =
{
    0xD18000,   /* Address of BL_Array_D1 */
    0xD28000,   /* Address of BL_Array_D2 */
    0xD38000,   /* Address of BL_Array_D3 */
    0xD48000,   /* Address of BL_Array_D4 */
    0xD58000,   /* Address of BL_Array_D5 */
    0xD68000    /* Address of BL_Array_D6 */
};
#pragma CONST_SEG DEFAULTAlso I would modify the initialization of pBootloadArray as follows:
pBootloaderArray = ( uint8 const __far * )(BL_PtrToArray[NumOfBlks]);
Please refer to TN238.pdf in {Install}\Help\PDF for more information on how to define variable, constants in paged memory.
CrasyCat
 
					
				
		
Thanks CrasyCat
