Skip to end of banner
Go to start of banner

Custom Buffer Write and Verify - GangPro-ARM

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

This code example writes custom bytes to the Gang Write Buffers (6) within the API-DLL, programs the buffers to targets' flash, and then verifies the programmed data using direct read-back of the targets' flash. This example is geared towards multiple targets GangPro-ARM library.

The condition for this example to work properly is that F_OpenInstancesAndFPAs, and F_Initialization has correctly initialized the given fpa index (1 to 64). If testing adapter 1, the user should call F_Set_FPA_index(1) before this code executes. In addition the user should load the intended configuration file using F_ConfigFileLoad so that the right MCU is selected.

MCU_Info struct was initialized using example Get MCU Info.

The code sequence is as follows:

  • Power on target devices and open communication using F_Open_Target_Device

  • The return value is a TRUE MASK (0x01..0x3F) : 0x01 - target 1, 0x02 - target 2, 0x04 - target 3, 0x08 - target
    4, 0x10 - target 5, 0x20 - target 6, if at least one target succeeded then proceed further.

  • Get MCU base flash address, MCU_Info.u.x.FlashStartAddr, and add 0x100. This code will write custom bytes to almost the start of flash.

  • In a loop, populate the Gang Write Buffer for target 1 with custom bytes starting at address addr using F_Put_Byte_to_Gang_Buffer. The user can change the first parameter to write different bytes to target 2, 3, 4, 5, or 6.

  • Program custom bytes to targets using F_Copy_Gang_Buffer_to_Flash

  • Read target memories and save contents to Gang Read Buffers (6) using F_Copy_Flash_to_Gang_Buffer

  • In a loop, read bytes from the Gang Read Buffers and print them using F_Get_Byte_from_Gang_Buffer, this example iterates over 6 target buffers.

  • Power down targets and close communication using F_Close_Target_Device

#define ANY_TARGET 0x3F
INT_X response;
const int size=32;

response = F_Open_Target_Device();
if((response & ANY_TARGET) == 0)
  return response;
  
char text[1000];	  
long addr = MCU_Info.u.x.FlashStartAddr + 0x100;
for(int k=0; k< size; k++)
{
  //----------------------------------------------------
  F_Put_Byte_to_Gang_Buffer( 1, (INT_X )(addr+k), (BYTE)( 0x10 + k ));
  //----------------------------------------------------
}
//----------------------------------------------------
response = F_Copy_Gang_Buffer_to_Flash( addr, size );
if((response & ANY_TARGET) == 0)
  return response;
//----------------------------------------------------

//----------------------------------------------------
response = F_Copy_Flash_to_Gang_Buffer( addr, size );
if((response & ANY_TARGET) == 0)
  return response;
//----------------------------------------------------

if( F_Get_Active_Targets_Mask() == response )
{
  sprintf( text, "Read from FLASH - address 0x%4.4X\r\n", addr );
  printf("%s", text);
  for(int p=0; p<GANG_SIZE; p++)			
  {
    for( int n=0; n<size; n += 16 )
    {
      for( int k = 0; k<16; k++ )
      {
        //----------------------------------------------------
        sprintf( text+3*k, "%2.2X  ", F_Get_Byte_from_Gang_Buffer( (p+1), (INT_X )( addr + k + n) ));//for gang buffer, when reading in GangPro
        
        //----------------------------------------------------
      }
      strcat( text, "\r\n" );
      printf("%s", text);
    }
  }
}

response = F_Close_Target_Device();
if((response & ANY_TARGET) == 0)
  return response;

  • No labels