eTPU interface & Precompiled binaries for ST SPC56xx?

ChibiOS public support forum for topics related to the STMicroelectronics SPC56x family of automotive micro-controllers.
jafrey
Posts: 33
Joined: Tue Nov 05, 2013 12:15 am

eTPU interface & Precompiled binaries for ST SPC56xx?

Postby jafrey » Tue May 06, 2014 8:45 pm

Two questions:

1) How does ChibiOS interact with the eTPU? One of the huge advantages of the PPC platform is the availability of the eTPU/eTPU2.

2) Does ST have a set of precompiled eTPU functionality? Freescale has a set of generic, precompiled binaries for use with their chips. Is it possible to use those from Freescale?. eTPU compilers are very expensive for the home user and I haven't found a single open-sourced eTPU C compiler anywhere.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: eTPU interface & Precompiled binaries for ST SPC56xx?

Postby Giovanni » Wed May 07, 2014 7:54 am

Hi,

Yes, the binaries from Freescale are usable on ST parts too, most SPC56xx/MPC56xx the devices are exactly the same. I heard there is an eTPU assembler somewhere but I never tried it.

Giovanni

jafrey
Posts: 33
Joined: Tue Nov 05, 2013 12:15 am

Re: eTPU interface & Precompiled binaries for ST SPC56xx?

Postby jafrey » Wed May 07, 2014 2:43 pm

Giovanni wrote:Hi,

Yes, the binaries from Freescale are usable on ST parts too, most SPC56xx/MPC56xx the devices are exactly the same. I heard there is an eTPU assembler somewhere but I never tried it.

Giovanni


How do you interact with the eTPU from ChibiOS?

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: eTPU interface & Precompiled binaries for ST SPC56xx?

Postby Giovanni » Wed May 07, 2014 2:51 pm

There is not (yet) an "eTPU driver" so you would have to initialize it yourself.

After that basically it just generates interrupts that can wakeup threads using one of the available mechanisms: events, semaphores etc.

Giovanni

jafrey
Posts: 33
Joined: Tue Nov 05, 2013 12:15 am

Re: eTPU interface & Precompiled binaries for ST SPC56xx?

Postby jafrey » Wed May 07, 2014 3:45 pm

Giovanni wrote:There is not (yet) an "eTPU driver" so you would have to initialize it yourself.

After that basically it just generates interrupts that can wakeup threads using one of the available mechanisms: events, semaphores etc.

Giovanni


I guess I'll have to read up on the eTPU from ST and Freescale. I'm actually interested in using it for the injector drivers and engine speed and offloading all that processing from the main CPU. (Like the big boys do in the automotive world).

Nobody
Posts: 8
Joined: Wed May 14, 2014 3:17 am

Re: eTPU interface & Precompiled binaries for ST SPC56xx?

Postby Nobody » Sun May 18, 2014 7:23 am

jafrey wrote:I guess I'll have to read up on the eTPU from ST and Freescale. I'm actually interested in using it for the injector drivers and engine speed and offloading all that processing from the main CPU. (Like the big boys do in the automotive world).


Here is a quick example for and very simple 4-cyclinder engine (far from complete). I have not tried it with SPC5 studio yet, but will give it a shot when time permits.

This is a publically available function set for eTPU, there are many variations (most not public). This one covers 3-6 cylinder engines. The multi-spark, not sure why as it is far from common on induction type coils, especially coil near plug. As can be seen eTPU functions can be very robust and why anything having to do with an internal combustion engine (ICE), is a great fit for this MPU w/TPU.

Notes:
* TPU TCR2 must be set for angle.
* Angle in this function set is 0-71999 or 0-719.99 degrees (this is a 4-stroke).
* Time base is in uS (microseconds).
* Crank and cam inputs must be first 2 TPU input channels.
* Typical crank is 36 tooth, 35 teeth with 1 missing tooth as reference mark.
* Missing tooth is almost always before TDC (top dead center) for cylinder 1.
* Cam sensor to determine if it’s a compression or exhaust stroke.
* “Tooth Generator” is what it sounds like, a simulation output that goes to crank and cam inputs.


Code: Select all

/************************************************************************
 *    This file was generated by eTPU Graphical Configuration Tool       
 *                                                                       
 *    DO NOT EDIT !!! DO NOT EDIT !!! DO NOT EDIT !!! DO NOT EDIT !!!     
 *                                                                       
 *  DESCRIPTION:
 *  This file contains my_system_etpu_init and my_system_etpu_start
 *  functions and related items. The function initialize the eTPU
 *  global and channel settings, based on the user settings
 *  in the eTPU GCT, and runs the eTPU.               
 *  A header file of the same name .h is also generated.                   
 *
 *  Creation Date:  5/18/2014 1:00:54 AM
 *
 **************************************************************************/

/* general routines */
#include "etpu_util.h"             /* Utility routines for working eTPU */
#include "mpc563m_vars.h"          /* Processor dependent variables */

/* eTPU function set used */
#include "etpu/_etpu_set/etpu_set.h"       

/* eTPU functions APIs */
#include "etpu/fuel/etpu_fuel.h" /* Fuel */
#include "etpu/spark/etpu_spark.h" /* Spark */
#include "etpu/toothgen/etpu_toothgen.h" /* ToothGen - Tooth Generator */
#include "etpu/engine_position/etpu_app_eng_pos.h" /* Engine Position (CAM and CRANK channels): main header file */
#include "etpu/ic/etpu_ic.h" /* IC */

/* our private header file (generated by eTPU GCT) */
#include "small_eng_etpu_gct.h"



/* External object declarations */
/* ... no external variables used */


/**************************************************************************
 *
 * Global Variables
 *
 **************************************************************************/

uint32_t *fs_free_param;

/**************************************************************************
 *
 * CPU and clock configuration:
 *
 *   CPU = MPC5634M
 *   SYSCLK = 80 MHz
 *   Input_TCRCLK_A = OFF
 *   Input_TCRCLK_B = OFF
 *   
 **************************************************************************/

uint32_t etpu_a_tcr1_freq = 40000000;
uint32_t etpu_a_tcr2_freq = 10000000;
uint32_t etpu_b_tcr1_freq = 0;
uint32_t etpu_b_tcr2_freq = 10000000;


/**************************************************************************
 *
 * etpu_config structure filled accodring to the user settings
 *
 **************************************************************************/

struct etpu_config_t my_etpu_config =
{
  /* etpu_config.mcr */
  FS_ETPU_VIS_OFF   /* SCM not visible (VIS=0) */
  | FS_ETPU_MISC_DISABLE   /* SCM operation disabled (SCMMISEN=0) */,

  /* etpu_config.misc */
  FS_ETPU_MISC,

  /* etpu_config.ecr_a */
  FS_ETPU_ENTRY_TABLE_ADDR   /* entry table base address = shifted FS_ETPU_ENTRY_TABLE */
  | FS_ETPU_CHAN_FILTER_2SAMPLE   /* channel filter mode = two-sample mode (CDFC=0) */
  | FS_ETPU_ENGINE_DISABLE   /* engine is stopped (MDIS=1) */
  | FS_ETPU_FILTER_CLOCK_DIV2   /* channel filter clock = etpuclk div 2 (FPSCK=0) */,

  /* etpu_config.tbcr_a */
  FS_ETPU_ANGLE_MODE_ENABLE   /* TCR2 works in angle mode (AM=1) */
  | FS_ETPU_TCR2_PRESCALER(1)   /* TCR2 prescaler = 1 (TCR2P='1-1') */
  | FS_ETPU_TCR1_PRESCALER(1)   /* TCR1 prescaler = 1 (TCR1P='1-1') */
  | FS_ETPU_TCRCLK_MODE_INTEGRATION   /* TCRCLK signal is filtered using integration mode (TCRCF=1x) */
  | FS_ETPU_TCR2CTL_GATEDDIV8   /* TCR2 source = etpuclk div 8, gated by TCRCLK (TCR2CTL=0) */
  | FS_ETPU_TCRCLK_INPUT_CHANCLOCK   /* TCRCLK signal is filtered with filter clock = channel filter clock (TCRCF=x1) */
  | FS_ETPU_TCR1CTL_DIV2   /* TCR1 source = etpuclk div 2 (TCR1CTL=2) */,

  /* etpu_config.stacr_a */
  FS_ETPU_TCR1_STAC_SERVER   /* TCR1 resource operates as server (RSC1=1) */
  | FS_ETPU_TCR2_STAC_SERVER   /* TCR2 resource operates as server (RSC2=1) */
  | FS_ETPU_TCR1_STAC_DISABLE   /* TCR1 operation on STAC bus disabled (REN1=0) */
  | FS_ETPU_TCR2_STAC_DISABLE   /* TCR2 operation on STAC bus disabled (REN2=0) */
  | FS_ETPU_TCR1_STAC_SRVSLOT(0)   /* TCR1 resource server slot = 0 (SRV1=0) */
  | FS_ETPU_TCR2_STAC_SRVSLOT(0)   /* TCR2 resource server slot = 0 (SRV2=0) */,

  /* etpu_config.ecr_b */
  0,

  /* etpu_config.tbcr_b */
  0,

  /* etpu_config.stacr_b */
  0
};

/**************************************************************************
 *
 *  FUNCTION : my_system_etpu_init
 *
 *  PURPOSE  : Initializes the eTPU settings and channel settings, based
 *             on the user settings in the eTPU GCT:
 *
 *             1. Initialize global setting using fs_etpu_init function
 *                and the my_etpu_config structure.
 *             2. Initialize channel setting using channel function APIs
 *                or standard eTPU routines.
 *
 *  RETURNS  : If the initialization of all channel functions passed OK,
 *             the return value is 0. If the initialization of a channel
 *             failed, the returned value is a number of the channel that
 *             failed to initialized increased by 1.
 *
 **************************************************************************/

int32_t my_system_etpu_init()
{
  int32_t err_code;

  /*
   *  Initialization of eTPU global settings
   */

  fs_etpu_init( my_etpu_config, (uint32_t *)etpu_code, sizeof(etpu_code),
                (uint32_t *)etpu_globals, sizeof(etpu_globals));

  /*
   *  Initialization of eTPU channel settings
   */

  /*
   *  eTPU API Function initialization: 'Fuel'
   */
  err_code = fs_etpu_fuel_init_4cylinders (FUEL0_FUEL_1,   /* engine: A; channel: 2 */
                                           FUEL0_FUEL_2,   /* engine: A; channel: 3 */
                                           FUEL0_FUEL_3,   /* engine: A; channel: 4 */
                                           FUEL0_FUEL_4,   /* engine: A; channel: 5 */
                                           0,   /* cam_chan: 0 */
                                           FS_ETPU_PRIORITY_LOW,   /* priority: Low */
                                           FS_ETPU_FUEL_PULSE_HIGH,   /* polarity: Pulse active high */
                                           0,   /* cylinder_offset_angle_1: 0 */
                                           0,   /* cylinder_offset_angle_2: 0 */
                                           0,   /* cylinder_offset_angle_3: 0 */
                                           0,   /* cylinder_offset_angle_4: 0 */
                                           0,   /* drop_dead_angle: 0 */
                                           0,   /* injection_normal_end_angle: 0 */
                                           0,   /* recalculation_offset_angle: 0 */
                                           0,   /* injection_time_us_1: 0 */
                                           0,   /* injection_time_us_2: 0 */
                                           0,   /* injection_time_us_3: 0 */
                                           0,   /* injection_time_us_4: 0 */
                                           0,   /* compensation_time_us: 0 */
                                           0,   /* minimum_injection_time_us: 0 */
                                           0);   /* minimum_off_time_us: 0 */
  if (err_code != 0)
     return ((FUEL0_FUEL_1) + 1);
 
  /*
   *  eTPU API Function initialization: 'Spark'
   */
  err_code = fs_etpu_spark_init_4cylinders (SPARK0_SPARK_1,   /* engine: A; channel: 6 */
                                            SPARK0_SPARK_2,   /* engine: A; channel: 7 */
                                            SPARK0_SPARK_3,   /* engine: A; channel: 8 */
                                            SPARK0_SPARK_4,   /* engine: A; channel: 9 */
                                            0,   /* cam_chan: 0 */
                                            17999,   /* cyl_offset_angle_1: 17999 */
                                            35999,   /* cyl_offset_angle_2: 35999 */
                                            53999,   /* cyl_offset_angle_3: 53999 */
                                            71999,   /* cyl_offset_angle_4: 71999 */
                                            FS_ETPU_PRIORITY_MIDDLE,   /* priority: Middle */
                                            FS_ETPU_SPARK_ACTIVE_HIGH,   /* polarity: FS_ETPU_SPARK_ACTIVE_HIGH */
                                            3000,   /* min_dwell_time: 3000 */
                                            10000,   /* max_dwell_time: 10000 */
                                            0,   /* multi_on_time: 0 */
                                            0,   /* multi_off_time: 0 */
                                            0,   /* multi_num_pulses: 0 */
                                            0,   /* recalc_offset_angle: 0 */
                                            0,   /* init_dwell_time_1: 0 */
                                            0,   /* init_dwell_time_2: 0 */
                                            0,   /* init_end_angle_1: 0 */
                                            0);   /* init_end_angle_2: 0 */
  if (err_code != 0)
     return ((SPARK0_SPARK_1) + 1);
 
  /*
   *  eTPU API Function initialization: 'ToothGen - Tooth Generator'
   */
  err_code = fs_etpu_toothgen_init (TOOTHGEN0_CRANK,   /* engine: A; channel: 14 */
                                    TOOTHGEN0_CAM,   /* engine: A; channel: 15 */
                                    FS_ETPU_PRIORITY_LOW,   /* priority: Low */
                                    35,   /* crank_number_of_physical_teeth: 35 */
                                    1,   /* crank_number_of_missing_teeth: 1 */
                                    0x000FFF,   /* tooth_duty_cycle: 0x000FFF */
                                    36,   /* tooth_number: 36 */
                                    2500,   /* engine_speed_rpm: 2500 */
                                    40000000,   /* tcr1_timebase_freq: 40000000 */
                                    3,   /* cam_start: 3 */
                                    4);   /* cam_stop: 4 */
  if (err_code != 0)
     return ((TOOTHGEN0_CRANK) + 1);
 
  /*
   *  eTPU API Function initialization: 'Engine Position (CAM and CRANK channels)'
   */
  err_code = fs_etpu_app_eng_pos_init (APP_ENG_POS0_CAM,   /* engine: A; channel: 0 */
                                       FS_ETPU_CAM_PRIORITY_HIGH,   /* cam_priority: High */
                                       FS_ETPU_CAM_FM0_RISING_EDGE,   /* cam_edge_polarity: FS_ETPU_CAM_FM0_RISING_EDGE */
                                       0,   /* cam_angle_window_start: 0 */
                                       0,   /* cam_angle_window_width: 0 */
                                       APP_ENG_POS0_CRANK,   /* engine: A; channel: 1 */
                                       FS_ETPU_CRANK_PRIORITY_HIGH,   /* crank_priority: High */
                                       FS_ETPU_CRANK_FM0_RISING_EDGE,   /* crank_edge_polarity: FS_ETPU_CRANK_FM0_RISING_EDGE */
                                       0,   /* crank_number_of_physical_teeth: 0 */
                                       0,   /* crank_number_of_missing_teeth: 0 */
                                       0,   /* crank_blank_tooth_count: 0 */
                                       0,   /* crank_tcr2_ticks_per_tooth: 0 */
                                       0,   /* crank_windowing_ratio_normal: 0 */
                                       0,   /* crank_windowing_ratio_after_gap: 0 */
                                       0,   /* crank_windowing_ratio_across_gap: 0 */
                                       0,   /* crank_windowing_ratio_timeout: 0 */
                                       0,   /* crank_gap_ratio: 0 */
                                       0,   /* crank_blank_time_ms: 0 */
                                       0,   /* crank_first_tooth_timeout_us: 0 */
                                       0,   /* crank_link_1: 0 */
                                       0,   /* crank_link_2: 0 */
                                       0,   /* crank_link_3: 0 */
                                       0,   /* crank_link_4: 0 */
                                       0);   /* tcr1_timebase_freq: 0 */
  if (err_code != 0)
     return ((APP_ENG_POS0_CAM) + 1);
 
  /*
   *  eTPU API Function initialization: 'IC'
   */
  err_code = fs_etpu_ic_init (IC0_CHANNEL,   /* engine: A; channel: 10 */
                              FS_ETPU_PRIORITY_MIDDLE,   /* priority: Middle */
                              ETPU_IC_MODE_CONT,   /* mode: ETPU_IC_MODE_CONT */
                              FS_ETPU_TCR1,   /* timebase: TCR1 */
                              ETPU_IC_RISING_EDGE,   /* edge: ETPU_IC_RISING_EDGE */
                              4);   /* max_count: 4 */
  if (err_code != 0)
     return ((IC0_CHANNEL) + 1);
 
 

  return(0);
}

/**************************************************************************
 *
 *  FUNCTION : my_system_etpu_start
 *
 *  PURPOSE  : Initializes the eTPU settings and channel settings, based
 *             on the user settings in the eTPU GCT:
 *
 *             1. Initialize
 *                - Interrupt Enable
 *                - DMA Enable
 *                - Output Disable
 *                options of each channel.
 *             2. Run eTPU using Global Timebase Enable (GTBE) bit.
 *
 **************************************************************************/

void my_system_etpu_start()
{
  /*
   *  Initialization of Interrupt Enable, DMA Enable
   *  and Output Disable channel options
   */

  uint8_t i;
  uint32_t odis_a;
  uint32_t opol_a;

  eTPU->CIER_A.R = ETPU_CIE_A;

  eTPU->CDTRER_A.R = ETPU_DTRE_A;

  odis_a = ETPU_ODIS_A;
  opol_a = ETPU_OPOL_A;
  for(i=0; i<32; i++) {
    eTPU->CHAN[i].CR.B.ODIS = odis_a & 0x00000001;
    eTPU->CHAN[i].CR.B.OPOL = opol_a & 0x00000001;
    odis_a >>= 1;
    opol_a >>= 1;
  }

  /*
   *  Synchronous start of all TCR time bases
   */

  fs_timer_start();
}

/**************************************************************************
 *
 * Private GCT-generated data may follow this comment
 *
 **************************************************************************/



Code: Select all

/************************************************************************
 *    This file was generated by eTPU Graphical Configuration Tool       
 *                                                                       
 *    DO NOT EDIT !!! DO NOT EDIT !!! DO NOT EDIT !!! DO NOT EDIT !!!     
 *                                                                       
 *  DESCRIPTION:
 *  This file is generated together with the same name .c file.
 *  It contains function prototypes and useful defines.
 *
 *  Creation Date:  5/18/2014 1:00:54 AM
 *
 **************************************************************************/

/**************************************************************************
 * general macros
 **************************************************************************/
#define FS_ETPU_TCR1_PRESCALER(x)    (((x)-1) & 0xFF)
#define FS_ETPU_TCR2_PRESCALER(x)    ((((x)-1) & 0x3F)<<16)
#define FS_ETPU_TCR1_STAC_SRVSLOT(x) (((x) & 0xF)<<16)
#define FS_ETPU_TCR2_STAC_SRVSLOT(x) ((x) & 0xF)
#define FS_ETPU_CHANNEL_FUNCTION(x)  ((x) & 0x1F)
#define FS_ETPU_CHANNEL_PARAMS(x)    ((x) & 0x7F)
#define FS_ETPU_FUNCTION_MODE(x)     ((x) & 0x3)

#define FS_ETPU_ENTRY_TABLE_ADDR     (((FS_ETPU_ENTRY_TABLE)>>11) & 0x1F)

#define FS_ETPU_FUNCTION_MODE_00     FS_ETPU_FUNCTION_MODE(0)
#define FS_ETPU_FUNCTION_MODE_01     FS_ETPU_FUNCTION_MODE(1)
#define FS_ETPU_FUNCTION_MODE_10     FS_ETPU_FUNCTION_MODE(2)
#define FS_ETPU_FUNCTION_MODE_11     FS_ETPU_FUNCTION_MODE(3)

#define FS_ETPU_HSR_0                (0)
#define FS_ETPU_HSR_1                (1)
#define FS_ETPU_HSR_2                (2)
#define FS_ETPU_HSR_3                (3)
#define FS_ETPU_HSR_4                (4)
#define FS_ETPU_HSR_5                (5)
#define FS_ETPU_HSR_6                (6)
#define FS_ETPU_HSR_7                (7)

#define ETPU_ENGINE_A_CHANNEL(x)  (x)
#define ETPU_ENGINE_B_CHANNEL(x)  ((x)+64)
#define ETPU_CHAN_NOT_USED        (-1)

/**************************************************************************
 * define functions to channels
 **************************************************************************/
#define FUEL0_FUEL_1   ETPU_ENGINE_A_CHANNEL(2)
#define FUEL0_FUEL_2   ETPU_ENGINE_A_CHANNEL(3)
#define FUEL0_FUEL_3   ETPU_ENGINE_A_CHANNEL(4)
#define FUEL0_FUEL_4   ETPU_ENGINE_A_CHANNEL(5)
#define SPARK0_SPARK_1   ETPU_ENGINE_A_CHANNEL(6)
#define SPARK0_SPARK_2   ETPU_ENGINE_A_CHANNEL(7)
#define SPARK0_SPARK_3   ETPU_ENGINE_A_CHANNEL(8)
#define SPARK0_SPARK_4   ETPU_ENGINE_A_CHANNEL(9)
#define TOOTHGEN0_CRANK   ETPU_ENGINE_A_CHANNEL(14)
#define TOOTHGEN0_CAM   ETPU_ENGINE_A_CHANNEL(15)
#define APP_ENG_POS0_CAM   ETPU_ENGINE_A_CHANNEL(0)
#define APP_ENG_POS0_CRANK   ETPU_ENGINE_A_CHANNEL(1)
#define IC0_CHANNEL   ETPU_ENGINE_A_CHANNEL(10)

/**************************************************************************
 * Interrupt Enable, DMA Enable and Output Disable options
 * filled accodring to the user settings
 **************************************************************************/
#define ETPU_CIE_A    0x00000000
#define ETPU_DTRE_A   0x00000000
#define ETPU_ODIS_A   0x00003fff
#define ETPU_OPOL_A   0x00003ffc

/**************************************************************************
 * function prototypes
 **************************************************************************/
int32_t my_system_etpu_init ();
void    my_system_etpu_start();


Last edited by Nobody on Sun May 18, 2014 7:50 am, edited 2 times in total.

Nobody
Posts: 8
Joined: Wed May 14, 2014 3:17 am

Re: eTPU interface & Precompiled binaries for ST SPC56xx?

Postby Nobody » Sun May 18, 2014 7:34 am

Code: Select all

/****************************************************************
 * WARNING this file is automatically generated DO NOT EDIT IT! *
 *                                                              *
 * FILE NAME: etpu_set.h           COPYRIGHT (c) Freescale 2006 *
 *                                      All Rights Reserved     *
 *                                                              *
 * DESCRIPTION: User eTPU Functions - image file.               *
 *                                                              *
 * GENERATED BY: etpuc_set.c                                    *
 *                                                              *
 ***************************************************************/
#ifndef _ETPU_SET_H_
#define _ETPU_SET_H_

#define FS_ETPU_ENTRY_TABLE  0x0000
#define FS_ETPU_MISC         0xE50BE6CC

const uint32_t etpu_globals[] = { 0x000000FF,0x00000000,0x00000000,0x00000000,
                                  0x00000000,0x00000000,0x00000000,0x00000000,
                                  0x00000000,0x00000000,0x00000000,0x00000000,
                                  0x00000000,0x00000000,0x00000000,0x00000000
                                   };

const uint32_t etpu_code[] = { 0x41874187,0x41874187,0x41844182,0x41804192,
                               0x417F417E,0x41944194,0x41A041A0,0x41A041A0,
                               0x41944194,0x41944194,0x41944194,0x41944194,
                               0xC1A2C1A2,0xC1A2C1A2,0x41A041A0,0x41944194,
                               0x41BA41BF,0x41BA41BF,0x41C301A4,0xC1F0C1F0,
                               0xC1F041DD,0xC1F041CE,0xC1F041DD,0xC1F041CE,
                               0x41EAC1F0,0x41EAC1F0,0x41EAC1F0,0x41EAC1F0,
                               0x41EA41DD,0x41EA41CE,0x41EA41DD,0x41EA41CE,
                               0xC231C231,0xC231C231,0xC231C231,0xC2310207,
                               0x020401F7,0x4209422D,0x4209422D,0x4209422D,
                               0x4209422D,0x4209422D,0x4209422D,0x4209422D,
                               0xC231C231,0xC231C231,0x4209422D,0x4209422D,
                               0x427A427A,0x427A427A,0x42780233,0xC281C281,
                               0xC281C281,0xC281C281,0xC281C281,0xC281C281,
                               0xC281C281,0xC281C281,0xC281C281,0xC281C281,
                               0x427C427C,0x427C427C,0x427C427C,0x427C427C,
                               0x428E428E,0x428E428E,0xC2AE0283,0xC2AEC2AE,
                               0x429DC2AE,0x429DC2AE,0x429DC2AE,0x429DC2AE,
                               0x42994295,0x42994295,0x42994295,0x42994295,
                               0x429D4295,0x429D4295,0x429D4295,0x429D4295,
                               0xC352C352,0xC352C352,0x02D802DA,0xC352C352,
                               0x430242ED,0x431C433A,0x430242ED,0x431C433A,
                               0x430242ED,0x431C433A,0x430242ED,0x431C433A,
                               0x430242ED,0x431C433A,0x430242ED,0x431C433A,
                               0xC3FFC3FF,0xC3FFC3FF,0x035C035E,0x03584356,
                               0x43540360,0x038F038F,0x43FB43FD,0x43FB43FD,
                               0x43FB43FD,0x43FB43FD,0x439443C1,0x439443C1,
                               0x038F038F,0x038F038F,0x038F038F,0x038F038F,
                               0xC467C467,0xC467C467,0x04130401,0x04390439,
                               0x0461444B,0x44654420,0x0461444B,0x44654420,
                               0x445B0461,0x44324465,0x445B0461,0x44324465,
                               0x445B444B,0x44324420,0x445B444B,0x44324420,
                               0xC472C472,0xC472C472,0xC472C472,0x046F046C,
                               0x046A0468,0x04710471,0xC472C472,0xC472C472,
                               0xC472C472,0xC472C472,0xC472C472,0xC472C472,
                               0x04710471,0x04710471,0x04710471,0x04710471,
                               0x048A0487,0x048A0487,0x04840473,0xC4CCC4CC,
                               0x44A144A1,0x44A644A6,0x44A144A1,0x44A644A6,
                               0x44B244B2,0x44C444C4,0x44B244B2,0x44C444C4,
                               0xC4CCC4CC,0xC4CCC4CC,0xC4CCC4CC,0xC4CCC4CC,
                               0xC549C549,0xC549C549,0x04CE04D6,0xC549C549,
                               0x44DB44EB,0x451D451D,0x44DB44EB,0x451D451D,
                               0xC549C549,0x45114511,0xC549C549,0x45114511,
                               0x44DB44EB,0x45114511,0x44DB44EB,0x45114511,
                               0x0556455E,0x0556455E,0x455F054B,0xC5D8C5D8,
                               0x45604574,0x45AC45AC,0x45604574,0x45AC45AC,
                               0xC5D8C5D8,0x459A459A,0xC5D8C5D8,0x459A459A,
                               0x45604574,0x459A459A,0x45604574,0x459A459A,
                               0x4B084B08,0x4B084B08,0x4B074AEE,0xCB6ACB6A,
                               0xCB6ACB6A,0xCB6ACB6A,0xCB6ACB6A,0xCB6ACB6A,
                               0x4B694B50,0x4B694B39,0x4B204B69,0x4B094B69,
                               0x4B694B50,0x4B694B39,0x4B204B69,0x4B094B69,
                               0xCC62CC62,0xCC62CC62,0x4B6CCC62,0xCC62CC62,
                               0xCC62CC62,0xCC62CC62,0xCC62CC62,0xCC62CC62,
                               0x4B944BB7,0x4B8A4BB7,0x4B944BB7,0x4B8A4BB7,
                               0x4B944BB7,0x4B8A4BB7,0x4B944BB7,0x4B8A4BB7,
                               0x4C644C64,0x4C644C64,0xCC6ECC6E,0xCC6ECC6E,
                               0xCC6ECC6E,0x4C6B4C6B,0x4C6B4C6B,0x4C6B4C6B,
                               0xCC6ECC6E,0xCC6ECC6E,0x4C6B4C6B,0x4C6B4C6B,
                               0xCC6ECC6E,0xCC6ECC6E,0x4C6B4C6B,0xCC6ECC6E,
                               0x4C704C70,0x4C704C70,0xCCB9CCB9,0xCCB9CCB9,
                               0xCCB9CCB9,0x4C7B4C7B,0x4CA24C7B,0x4C7B4CA2,
                               0xCCB9CCB9,0xCCB9CCB9,0x4CA24C7B,0x4C7B4CA2,
                               0x4CB74CA0,0x4CA04CB7,0x4C7B4C7B,0x4CA04CA0,
                               0x4D0D4D0D,0x4D0D4D0D,0x0D030CFC,0x4D0D4D0D,
                               0x4D450D19,0x4D450D19,0x4D450D19,0x4D450D19,
                               0x4D510D4B,0x4D510D4B,0x4D510D4B,0x4D510D4B,
                               0x4D450D19,0x4D450D19,0x4D450D19,0x4D450D19,
                               0x063A063A,0x063A063A,0x06360626,0x08030803,
                               0x082C082C,0x082C082C,0x082C082C,0x082C082C,
                               0x08320832,0x08320832,0x08320832,0x08320832,
                               0x070906CB,0x064106A9,0x070906CB,0x064106A9,
                               0xC624C624,0xC624C624,0xC624C624,0x05E6C624,
                               0xC62405D9,0x461A461A,0x46204620,0x46204620,
                               0x461C461C,0x461C461C,0x05EC45FB,0x05EC45FB,
                               0x461A461A,0x461A461A,0x461A461A,0x461A461A,
                               0x48640838,0x48640838,0xC91F087F,0x087F087F,
                               0x49134908,0x48F948F9,0x49134908,0x48F948F9,
                               0x08A0088D,0x08D608D6,0x08A0088D,0x08D608D6,
                               0x08A0088D,0x48F948F9,0x08A0088D,0x48F948F9,
                               0x096B096B,0x096B096B,0xCA1A095E,0x4A194A19,
                               0x098E099C,0x09DC09E0,0x098E099C,0x09DC09E0,
                               0x09C209C7,0x099E4A19,0x09C209C7,0x099E4A19,
                               0x09C209C7,0x09DC09E0,0x09C209C7,0x09DC09E0,
                               0xC95CC95C,0xC95CC95C,0xC95CC95C,0xC95CC95C,
                               0xC95C0921,0x09210921,0x493F493F,0x493F493F,
                               0x493D493D,0x493D493D,0x493F493F,0x493F493F,
                               0x09210921,0x09210921,0x09210921,0x09210921,
                               0xCAB5CAB5,0xCAB5CAB5,0xCAB50A1C,0xCAB5CAB5,
                               0x0A300A71,0x0A300A71,0x0A300A71,0x0A300A71,
                               0x0A230A23,0x0A2F0A2F,0x0A230A23,0x0A2F0A2F,
                               0x0A230A23,0x0A2F0A2F,0x0A230A23,0x0A2F0A2F,
                               0xF3202E7F,0x3BF93FB4,0x0003301D,0xF2802EBF,
                               0x00033099,0xF2C02EFF,0x00033119,0xF2002F3F,
                               0x00033219,0xF2402F7F,0x00033819,0x9FF37A00,
                               0xFFFFCCF9,0x4FEFF6BF,0x47F8FBFE,0x47F8FDFE,
                               0xF7E030BF,0x59F9FFFF,0xF7E030BF,0x5AF9FFFF,
                               0x5BF9FFFF,0x4FF0FFF9,0xF73FFCFB,0xF3E8319F,
                               0x4FF9FFF9,0x4FF0FFFF,0xF7E031DF,0x3BFC2FF4,
                               0x4FF3FFFF,0x3BFD2FF4,0xBFEFFB80,0x3B1E2FF4,
                               0xBFFE7A83,0xF73FBCFB,0xF7E0331F,0x4FF9FFFF,
                               0xBFEFFB83,0xBFE80A80,0xBF197A83,0x7FF82E7B,
                               0xFFFF3CF9,0xFFFF7CF9,0xBFEFFB81,0xF76033FF,
                               0xB3F87A81,0xBFEFFB81,0xBDF87A81,0x6FFFFFFF,
                               0xF7E0331F,0x7FEFFFFF,0xFFC02E1F,0x6FFFFFFF,
                               0x580FF7E5,0xCFE9F980,0x0802ABA2,0xCFFFF980,
                               0x4FF33FFF,0xF3A835BF,0x39FD2FF4,0x4FF00FFF,
                               0x39FC2FF4,0xBFEFFB81,0x3B1E3FF4,0xBFF37A85,
                               0x7FFFFF5F,0xF3E036DF,0xFF3F0CFB,0x4F58FDFE,
                               0xF7E03A9F,0xFFFBFCF9,0x4FF8FBFE,0xFFFAFCF9,
                               0xF7E03C7F,0x4F3FFFFF,0xBFEFFB84,0xBFE80A81,
                               0xBF197A85,0xBFE80A80,0x6C193FDB,0xBFEFFB84,
                               0xBFE80A81,0xBF197A85,0x6FF83FDB,0xBFEFFB84,
                               0xBFE80A83,0xBF197A85,0xCFEFF980,0xF500395F,
                               0xBFEFFB85,0x7FF83FDB,0xBFEFFB82,0xBFFFFB80,
                               0xBFEFFB83,0xAFFFFB81,0xCFE8F980,0x0BF2ABD2,
                               0xCFFFF980,0xFFFF3CF9,0xCFEF7A80,0x3B1E2FF4,
                               0xBFEFFB81,0x3BF8FFF4,0xF0C03B3F,0xF7E03B5F,
                               0x4AFFFFFF,0x49FFFFFF,0xBFFE7A84,0xDFEF3A81,
                               0xAF1E7A85,0xCFE8F980,0x0BF2ABD2,0xCFFFF980,
                               0xFFFF3CF9,0xCFEF7A80,0x3B1E2FF4,0xBFEFFB81,
                               0x3BF8FFF4,0xF0C03D1F,0xF7E03D3F,0x49FFFFFF,
                               0x4AFFFFFF,0xF7C03B5F,0xBFEFFB85,0x3BF83FF4,
                               0xCFE9F980,0x0802ABA2,0xCFFFF980,0x6FFFFF9F,
                               0xFFC02E1F,0x6FFFFFFF,0x3BF01FD4,0x3BF11FD4,
                               0x3BF71FD4,0xFFFFCCF9,0x3BF21FD4,0xFFF8FCF9,
                               0x4FF00FFF,0x5B7FFFF9,0xCFEFF980,0xF548401F,
                               0x593FFFFF,0xCFEFF980,0xF508401F,0x5A5FFFFF,
                               0x4FF9FFFF,0xBFFFFF01,0xFF3FFCFB,0x47EFF6BF,
                               0xFFF8FCF9,0xF7E03F3F,0x4FF33FFF,0xF7E03F1F,
                               0xFFF9FCF9,0xBFEFFB81,0xBDF87A81,0xBFE80A80,
                               0x3819FFF4,0xF480421F,0xBFFE7A83,0xF7C0437F,
                               0xBFFE7A82,0xFFFF3CF9,0xF3A0431F,0xFFFF7CF9,
                               0xCFEFF885,0xFFC03E5F,0xCFEFF886,0xFFC03E5F,
                               0xF3C0437F,0xFF7FFCFB,0x47EFF6BF,0xF240459F,
                               0xBFEFFB81,0xBFE80A80,0x3819FFF4,0xF480445F,
                               0xBFF37A83,0x6FFFFFFF,0xBFF37A82,0xFFFF3CF9,
                               0xF3A0455F,0xFFFF7CF9,0xCFEFF885,0xFFC03E5F,
                               0xCFEFF886,0xFFC03E5F,0xF3C0459F,0xFF7FFCFB,
                               0x47EFF6BF,0xBFEFFB84,0x3BF82FF4,0xF7E0413F,
                               0x3BFE3FF4,0xFFC02E1F,0x6FFFFFFF,0x4FF83FED,
                               0xCFEFF982,0xF50847BF,0xCFEFF980,0xF508475F,
                               0xF7E0477F,0x4FFF0FFF,0x4FFF2FFF,0xF7E0483F,
                               0x3BFC3FF4,0xCFEFF980,0xF508481F,0x4FFF1FFF,
                               0x3BFD3FF4,0xF3E8497F,0x7FFFFFDF,0xF380491F,
                               0xBFEFFF86,0xFFEFFAD9,0xF7E0491F,0x3BF83FF4,
                               0xBFEFFB80,0xF7E049BF,0x3B133FF4,0xBFEFFB80,
                               0x3BF83FF4,0xBFF37A82,0x4F1FFFFF,0xCFEFF980,
                               0xF5484AFF,0xCFEFF980,0xF5884ABF,0xF7E04B5F,
                               0x4F5FFFFF,0x4F3FFFFF,0xF7C04B5F,0xCFEFF980,
                               0xF5884B5F,0x4F7FFFFF,0xBFEFFB81,0x3B132FF4,
                               0xBFFE7A83,0x48FFFFFF,0xCFEFF981,0xF5484CDF,
                               0xCFEFF981,0xF5884C9F,0xF7E04D3F,0x4AFFFFFF,
                               0x49FFFFFF,0xF7C04D3F,0xCFEFF981,0xF5884D3F,
                               0x4BFFFFFF,0x4FF3FFFF,0xCFEFF981,0xF5084E5F,
                               0xCFEFF982,0xF5084E1F,0xF7E04EBF,0x4FF0FFFF,
                               0x4FF1FFFF,0xF7C04EBF,0xCFEFF982,0xF5084EBF,
                               0x4FF2FFFF,0x7FFFFF5F,0xFF3F0CFB,0x500FF7FF,
                               0xF7E0467F,0x4F5FFFFF,0xF7E0467F,0x4F3FFFFF,
                               0x7FE37EBB,0xBFFFFB84,0xBFFE7A85,0xFFFF3CF9,
                               0xF7FF7CF9,0xFFC02E1F,0x6FFFFFFF,0x4819FFFF,
                               0x4FF0FFFF,0xCFEFF980,0x0802FBAA,0xF0C0513F,
                               0x4FF3FFFF,0xF3A8519F,0x591FFFFF,0x5AFFFFFF,
                               0x4FEFF6B9,0xF339FCFB,0x3BFC2FF4,0xCFEFF980,
                               0x0802FBAA,0xF0C0527F,0x3BFD2FF4,0xF7E052BF,
                               0xFF3FFCFB,0xBFFFFF06,0xBFFE7A83,0xCFE8FA81,
                               0x6F0E2E7B,0xBFFE7A84,0xBFEFFB86,0xBDF87A86,
                               0x6FEFFFFF,0xBFEFFB84,0xBFE80A83,0xBC197A85,
                               0xBFEFFF86,0xBFEFFB85,0x4FFFFFFF,0xBFFFFF80,
                               0xBFD5FA82,0xFFFF3CF9,0xF3E8553F,0xFFFF7CF9,
                               0xF77FFCFB,0xBFEFFB84,0xBFFFFB83,0xBFFFFF06,
                               0xBFEFFB81,0x6F1E2E7B,0xFFC02E1F,0x6FFFFFFF,
                               0x7FE94FE3,0xFFDFCCF9,0xBFEFFB82,0xBC0E0A80,
                               0xBF197A80,0xF080577F,0xCFEFF980,0x0A02AB82,
                               0xCFFFF980,0xFFFF3CF9,0xFFFF7CF9,0xFFDFCCF9,
                               0xBFFE7A82,0xBFEFFB81,0xFFFFCCF9,0x7F1E2E7B,
                               0xBFF37A82,0xBFEFFB81,0xFFFFCCF9,0x7F132E7B,
                               0xBFEFFB83,0xBDF87A83,0xBFE80A84,0x3819FFF4,
                               0xF4885A5F,0xBFEFFB80,0xBFFFFB85,0xCFEFF980,
                               0xCFFFF985,0xBFFFFF00,0xCFFFFD00,0xBFFFFF03,
                               0xFFFF3CF9,0xFFFF7CF9,0xFFDFCCF9,0xBFEFFB80,
                               0x3B130FF4,0x3BFE4FF4,0xFFFFCCF9,0xBC797A80,
                               0xF7E05B7F,0x4FF3FFFF,0x4FF0FFFF,0x4809F6BF,
                               0xFFFAFCF9,0x4FFFFFF9,0xF3E85CFF,0xFF3FFCFB,
                               0xFFE0561F,0x5B7FFFFF,0xF4005CBF,0xF7E05CDF,
                               0xFFF9FCF9,0xFFF8FCF9,0x6FFFFFFF,0xFFF8FCF9,
                               0xF3A05D7F,0x5A1FFFFF,0x59FFFFFF,0x7FEFFFFF,
                               0x6FFFFFFF,0xF200601F,0xFFC0561F,0xF4005E5F,
                               0xF7E05E7F,0xFFF9FCF9,0xFFF8FCF9,0xF3885F7F,
                               0xF4085F1F,0xFFC0579F,0xF7E05F5F,0xFFFBFCF9,
                               0xFFC05A7F,0xFFC0589F,0x6FFFFFFF,0xF400603F,
                               0xFFC0581F,0xF7E0603F,0xFFFBFCF9,0xF7C0603F,
                               0x7FFFFEFF,0x6FFFFFFF,0xF200635F,0xF3C862DF,
                               0xFFC0561F,0xF400611F,0xF7E0613F,0xFFF9FCF9,
                               0xFFF8FCF9,0xF380623F,0xF40061DF,0xFFC0579F,
                               0xF7E0621F,0xFFFBFCF9,0xFFC05A7F,0xFFC0589F,
                               0x6FFFFFFF,0xF408633F,0xFFC0581F,0xF7E0633F,
                               0xFFFBFCF9,0xF7C0633F,0xFFE0579F,0x7FEFFFFF,
                               0xFFFBFCF9,0x6FFFFFFF,0x7FFFFEFF,0x6FFFFFFF,
                               0xF20066FF,0xF3C8665F,0xFFC0561F,0xF400645F,
                               0xF7E0647F,0xFFF9FCF9,0xFFF8FCF9,0xF38865BF,
                               0xF400653F,0xFFC0565F,0xFFC0589F,0xF7E0659F,
                               0xFFFAFCF9,0xFFC0565F,0xFFC0581F,0xFFC0589F,
                               0x6FFFFFFF,0xCFEFF980,0x0802ABC2,0xCFFFF980,
                               0xFFFAFCF9,0x6FFFFFFF,0xFFE0565F,0x7FEFFFFF,
                               0xFFC0579F,0xFFC0589F,0x6FFFFFFF,0xFFC0565F,
                               0xFFC0579F,0x6FFFFFFF,0xF20069FF,0xFFC0561F,
                               0xF40067FF,0xF7E0681F,0xFFF9FCF9,0xFFF8FCF9,
                               0xF380695F,0xF40868DF,0xFFC0565F,0xFFC0589F,
                               0xF7E0693F,0xFFFAFCF9,0xFFC0565F,0xFFC0581F,
                               0xFFC0589F,0x6FFFFFFF,0xCFEFF980,0x0802ABA2,
                               0xCFFFF980,0xFFFAFCF9,0x6FFFFFFF,0xFFC0565F,
                               0xFFC0579F,0x6FFFFFFF,0xFFC02E1F,0x6FFFFFFF,
                               0xF7E06C1F,0x4F3FFFFF,0xF7E06C1F,0x4F5FFFFF,
                               0xCFEFF981,0x0902AB82,0xCFFFF981,0x47F8FFFF,
                               0xF7E06B1F,0x7FFFFDFE,0xF7E06B1F,0x7FFFFBFE,
                               0x4FF8FFE5,0xCFEFF981,0xF6C06CFF,0x4FFF3FFF,
                               0x3BFD3FF4,0xF7E06D5F,0x4FF3FFFF,0x4FFF0FFF,
                               0x3BFC3FF4,0x4FF0FFFF,0x7FFFFFDF,0xDFEFE981,
                               0xF5006EBF,0xCFEFF981,0xF5406E7F,0xBFEFFF83,
                               0xFFEFFAD9,0xF7E06EBF,0x3BF83FF4,0xBFEFFB82,
                               0x3BF83FF4,0xCFFFFD02,0xBFEFFF80,0xFFEFFAD9,
                               0xBFFFFB85,0xB7F87A85,0xF0806FBF,0xF7E06FDF,
                               0x4F3FFFFF,0x4F5FFFFF,0xBFEFFB85,0xBF033A80,
                               0x18187782,0xBFFFFB84,0xBFEFFF84,0xFFEFFAD9,
                               0xBFFFFB85,0xB7F87A85,0xF080713F,0xF7E0715F,
                               0x49FFFFFF,0x4AFFFFFF,0xBFEFFB85,0x7F132F5B,
                               0xFF3F0CFB,0x580FF7FF,0xF7F9FCF9,0xCFEFF981,
                               0xF680725F,0xF7C06C1F,0x4FFFF7FF,0x6FFFFFFF,
                               0x1C1F0F9E,0xBFEFFB84,0xF3A073FF,0xBF197A84,
                               0xBFEFFB84,0xBFE80A81,0x3819FFF4,0xF4C876DF,
                               0xBFEFFB80,0xBFFFFB84,0xF7C076DF,0xF3C076BF,
                               0xCFEFF980,0x0802FBAA,0xF0C0757F,0xBFEFFB84,
                               0xBFE80A81,0x3819FFF4,0xF4C876DF,0xFFF97CFB,
                               0xBFFE7A82,0xF7C07AFF,0xF7C076DF,0xBFEFFB84,
                               0xBFE80A81,0x3819FFF4,0xF4C876DF,0xBFEFFB80,
                               0xBFFFFB84,0xCFEFF980,0x32F2AFF4,0xCFFFF980,
                               0xF7C076DF,0xF7C0747F,0xBFEFFF84,0xFFEFFAD9,
                               0xBFFFFB85,0xB7F87A85,0xF08077BF,0xF7E077DF,
                               0x49FFFFFF,0x4AFFFFFF,0xBFEFFB85,0x7F132E7B,
                               0xF7F9FCF9,0x1C1F0F9E,0xBFEFFB84,0xF3A0799F,
                               0xBF197A84,0xBFEFFB84,0xBFE80A81,0x3819FFF4,
                               0xF4C87E1F,0xBFEFFB80,0xBFFFFB84,0xF7C07E1F,
                               0xF3C07DFF,0xCFEFF980,0x0802FBAA,0xF0C07CBF,
                               0xBFEFFB84,0xBFE80A81,0x3819FFF4,0xF4C87E1F,
                               0xFFF8FCF9,0xBFF37A82,0x7FFFFFBF,0xCFEFF982,
                               0x0802FBAA,0xF0C07C1F,0xFFFF3CF9,0xFFFF7CF9,
                               0x4FFFF7FF,0xCFEFF981,0x0AF2ABF2,0xCFFFF981,
                               0xCFEFF982,0x31F2AFF4,0xCFFFF982,0x6FFFFFFF,
                               0xF7C07E1F,0xBFEFFB84,0xBFE80A81,0x3819FFF4,
                               0xF4C87E1F,0xBFEFFB80,0xBFFFFB84,0xCFEFF980,
                               0x32F2AFF4,0xCFFFF980,0xF7C07E1F,0xF7C07A1F,
                               0xBFEFFF84,0xFFEFFAD9,0xBFFFFB85,0xB7F87A85,
                               0xF0807EFF,0xF7E07F1F,0x4F3FFFFF,0x4F5FFFFF,
                               0xBFEFFB85,0x7F1E3F9B,0xF7F8FCF9,0xF7E0729F,
                               0x3BF5FFB4,0xF7E0783F,0x3BF5FFB4,0xFFC02E1F,
                               0x6FFFFFFF,0x4FF8FDFE,0xFFFBFCF9,0xCFE9FE82,
                               0xFFEFFAD9,0xBFE80A80,0xBF092A80,0xBFFFFB8A,
                               0xBFEFFB81,0x3B1E3FF4,0xBFF37A89,0x7FFFFF5F,
                               0xFF3F0CFB,0xCFEFF884,0xFFC03E5F,0xCFEFF885,
                               0xFFC03E5F,0xBFFE7A86,0xF7C082FF,0x4FF8FDFE,
                               0xFFFAFCF9,0xCFF9FD01,0x7FFFFFFD,0xF3A0835F,
                               0x580006A5,0x4FF33FFF,0x495FFFFF,0xBFEFFB81,
                               0x3BF8FFF4,0xF0C083FF,0x4AFFFFFF,0x6FFFFFFF,
                               0xCFE8FA8A,0x3B1E2FF4,0x49FFFFFF,0xBFEFFB81,
                               0x3BF8FFF4,0xF0C084FF,0x4AFFFFFF,0xBFFE7A86,
                               0xDFEF3A81,0xBF1E7A89,0xBFEFFB80,0xBFFFFB8A,
                               0xCFEFF884,0xFFC03E5F,0xCFEFF885,0xFFC03E5F,
                               0xFFFF3CF9,0xF7FF7CF9,0xBFEFFB89,0x3BF83FF4,
                               0xF3E0871F,0xFFF9CCFB,0xFFFF3CF9,0xFFFF7CF9,
                               0x6FFFFFFF,0xCFEFF981,0x3BF20BF4,0xF0C088DF,
                               0x3DFFAFF4,0xCFFFF981,0xBFEFFF87,0xFFEFFAD9,
                               0xBFE80A83,0xBF092A81,0xBFFFFB8B,0x7F1E3F5B,
                               0xF7E0895F,0xFF3F0CFB,0xBFEFFF87,0xFFEFFAD9,
                               0xBFE80A83,0xBF197A86,0x47FFF7FF,0xF30089BF,
                               0xF7C088DF,0xBFEFFB86,0x3BF82FF4,0xFFF83CFB,
                               0x49FFFFFF,0xBFEFFB8B,0x3BF8FFF4,0xF0C08ABF,
                               0x4AFFFFFF,0xBFEFFB86,0xBFE80A8B,0xBF197A89,
                               0xBFEFFB81,0xBFFFFB8B,0x6FFFFFFF,0xF3008BBF,
                               0xF7C088DF,0xBFEFFB89,0x3BF83FF4,0xFFF9CCFB,
                               0x6FFFFFFF,0xF3008C7F,0xF7C088DF,0xFFC02E1F,
                               0x6FFFFFFF,0xFFC02E1F,0x6FFFFFFF,0x6FFFFFFF,
                               0x580FF7FF,0xF7FF3CF9,0x580FF7FF,0xF7FF7CF9,
                               0x580FF7FF,0xBFEFFB80,0x6FF81FF3,0x580FF7FF,
                               0xF7FFBCF9,0xF7C08D1F,0x6FFFFFFF,0x4FF00FFF,
                               0xFFF8FCF9,0x4FFFFFE5,0xF3A08F3F,0xFFFBFCF9,
                               0xFFFAFCF9,0xF3E88FBF,0x7FEFFEBF,0xF7E08FDF,
                               0x7FFFFDFE,0x7FFFFBFE,0x4FF8FFFF,0xFFFF3CF9,
                               0xFFFF7CF9,0xFF3FFCFB,0x3AF94F94,0x47F9FFFF,
                               0x4FF33FFF,0xF7E08EBF,0xFFF9FCF9,0xBFEFFB81,
                               0xF7E0919F,0x3B1D2FF4,0xBFEFFB81,0x3B1C2FF4,
                               0x7FEFFE3F,0x39F94F94,0xF3A0927F,0x4FF8FFFF,
                               0xBFEFFB80,0xF7E092BF,0xB7F87A80,0xBFEFFB80,
                               0xB3F87A80,0xF080931F,0xF7E0933F,0x7FFFFBFE,
                               0x7FFFFDFE,0x3AF94F94,0xCFEFF980,0xCFFFF981,
                               0xF3C093FF,0xF7E0941F,0x4AFFFFFF,0x49FFFFFF,
                               0x6FFFFFFF,0x7EF94EE3,0xF740955F,0xBFEFFB80,
                               0xBCF87A80,0xF7C0955F,0x7EF94EE3,0xF740955F,
                               0xBFEFFB80,0xBDF87A80,0x39F94F94,0xBFEFFB81,
                               0x3B1E3FF4,0x4F7FFFDF,0xCFEFF981,0x32F2AFF4,
                               0xCFFFF981,0x6FFFFFFF,0xDFEFD981,0x3BF20BF4,
                               0xF0C8983F,0x39F94F94,0xBFEFFB80,0xB7F87A80,
                               0xF080977F,0xF7E0979F,0x7FFFFBFE,0x7FFFFDFE,
                               0x3AF94F94,0xBFEFFB81,0x3B132FF4,0xF7E0987F,
                               0x4BFFFF7F,0xFFFF3CF9,0xFFFF7CF9,0x6FFFFFFF,
                               0x00000000,0x00000000,0x00000000,0x00000000,
                               0x00000000,0x00000000,0x00000000,0x00000000,
                               0x00000000,0x00000000,0x00000000,0x00000000,
                               0x00000000,0x00000000,0x00000000,0x00000000,
                               0x00000000,0x00000000,0x00000000,0x00000000,
                               0x00000000,0x00000000,0x00000000,0x00000000
                                };
/* List of functions:
"GPIO",
"PWM",
"IC",
"OC",
"FPM",
"PPA",
"QOM",
"SPWM",
"TEST",
"SPI",
"UART",
"UART_FC",
"HD",
"QD",
"QDHOME",
"QDINDEX",
"PWMMDC",
"Crank",
"Cam",
"Fuel",
"Spark",
"knock_window",
"TOOTHGEN",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
*/

#endif /* _ETPU_SET_H_ */


DELETED partial binary to fit char limit.

Code: Select all

/**************************************************************************
 * FILE NAME: $RCSfile: etpu_app_eng_pos.c,v $                    *
 *                                           COPYRIGHT (c) FREESCALE 2006 *
 *                                                  All Rights Reserved   *
 * DESCRIPTION:                                                           *
 * This file contains the eTPU Engine Position (eng_pos) API.             *
 *========================================================================*
 * ORIGINAL AUTHOR: Geoff Emerson (r47354)                                *
 * $Log: etpu_app_eng_pos.c,v $
 * Revision 1.6  2008/11/26 15:29:36  r47354
 * Add type for parameter in speed API.
 *
 * Revision 1.5  2008/11/13 10:49:10  r47354
 * Added fs_etpu_eng_pos_get_engine_speed function.
 *
 * Revision 1.4  2008/08/28 13:22:19  r47354
 * Fix issues with crank_blank_time_ms and crank_first_tooth_timeout_us calculations and limiting.
 * Make fs_etpu_eng_pos_get_engine_cycle_0_count fs_etpu_eng_pos_get_engine_cycle_0_tvr2_count
 * fs_etpu_eng_pos_insert_tooth now has host_asserted_tooth_count parameter.
 *
 * Revision 1.3  2008/06/23 14:22:55  r47354
 * Added range checking.
 * Added code for fs_etpu_eng_pos_set_wr_after_gap, fs_etpu_eng_pos_set_wr_across_gap, fs_etpu_eng_pos_set_wr_timeout
 *
 * Revision 1.2  2008/06/06 09:53:02  r47354
 * Major rework based on etpuc code changes and review.
 *
 * Revision 1.1  2008/01/21 13:49:05  r47354
 * Initial revision
 *
 *                                                                        *
 **************************************************************************/
#include "etpu_util.h"          /* Utility routines for working with the eTPU */
#include "etpu_app_eng_pos.h"             /* eTPU Engine Position API defines */
extern uint32_t fs_etpu_data_ram_start;

/**************************************************************************
 *
 * Global Variables
 *
 **************************************************************************/

uint8_t g_crank_channel, g_cam_channel;
/******************************************************************************
FUNCTION     : fs_etpu_app_eng_pos_init
PURPOSE      : To initialize 2 eTPU channels to for the synchronisation
               functions.
INPUTS NOTES : This function has the following parameters:
           cam_channel - This is the CAM channel number.
                         1-31 for FS_ETPU_A and 65-95 for FS_ETPU_B.               
          cam_priority - This is the priority to assign to the cam channel.
                         This parameter should be assigned a value of:
                         FS_ETPU_CAM_PRIORITY_HIGH, FS_ETPU_PRIORITY_CAM_MIDDLE
                         or FS_ETPU_CAM_PRIORITY_LOW.
     cam_edge_polarity - The polarity if the CAM edge. Can be
                         FS_ETPU_CAM_FM0_RISING_EDGE or
                         FS_ETPU_CAM_FM0_FALLING_EDGE           
cam_angle_window_start - The starting postion of the CAM window.
                         Range 0 to 71999. 71999 represents 719.99 degress
cam_angle_window_width - The width of the CAM window.
                         Range 0 to 71999. 71999 represents 719.99 degress
         crank_channel - This is the CRANK channel number.
                         0 for ETPU_A or 64 for ETPU_B.
        crank_priority - This is the priority to assign to the crank channel.
                         This parameter should be assigned a value of:
                         FS_ETPU_CRANK_PRIORITY_HIGH,
                         FS_ETPU_CRANK_PRIORITY_MIDDLE
                         or FS_ETPU_CRANK_PRIORITY_LOW.     
   crank_edge_polarity - The polarity if the CRANK edge. Can be
                         FS_ETPU_CRANK_FM0_RISING_EDGE or
                         FS_ETPU_CRANK_FM0_FALLING_EDGE.
crank_number_of_physical_teeth - number of physical teeth on the crank wheel.
                         Can be 1 to 255.
crank_number_of_missing_teeth - number of missing teeth on the crank wheel.
                         Can be 1,2 or 3.
crank_blank_tooth_count - Number of teeth to be ignored after first active edge.
                         Can be 0 to 255.
crank_tcr2_ticks_per_tooth - Number of TCR2 counts per tooth. Can be 1 to 1024.   
crank_windowing_ratio_normal - A fractional number. Used to window out noise.
                         Can be between 0x0 and 0xFFFFFF. Applied to 'noraml
                         teeth' - ratios below are used for other teeth.                         
crank_windowing_ratio_after_gap - A fractional number. Used to window out noise.
                         Can be between 0x0 and 0xFFFFFF. Applied to the
                         second tooth after the gap.                         
crank_windowing_ratio_across_gap - A fractional number. Used to window out 
                         noise. Can be between 0x0 and 0xFFFFFF. Applied to the
                         the first tooth after the gap.                         
crank_windowing_ratio_timeout - A fractional number. Used to window out noise.
                         Can be between 0x0 and 0xFFFFFF. Applied to the tooth
                         immediately following a timeout.
       crank_gap_ratio - A fractional number. Used to identify the gap. Can be 
                         between 0x0 and 0xFFFFFF.
   crank_blank_time_ms - The amount of time that teeth are ignored for at start
                         up in milli seconds. crank_blank_time_ms has a
                         maximum value given by:
                         ( 0xFFFFFF/tcr1_timebase_freq ) * 1000.         
crank_first_tooth_timeout_us - The amount of time in micro seconds after which 
                         the first tooth will be deemed to have have timed out.
                         Maximum value given by:
                         ( 0xFFFFFF/tcr1_timebase_freq ) * 1000000
          crank_link_1 - This is a packed 32 bit parameter with 4 8 bit
                         channel numbers in it. These channels are signalled
                         when CRANK has had to re-sync (e.g. STALL etc)
          crank_link_2 - This is a packed 32 bit parameter with 4 8 bit
                         channel numbers in it. These channels are signalled
                         when CRANK has had to re-sync (e.g. STALL etc)                               
          crank_link_3 - This is a packed 32 bit parameter with 4 8 bit
                         channel numbers in it. These channels are signalled
                         when CRANK has had to re-sync (e.g. STALL etc)                               
          crank_link_4 - This is a packed 32 bit parameter with 4 8 bit
                         channel numbers in it. These channels are signalled
                         when CRANK has had to re-sync (e.g. STALL etc)                               
    tcr1_timebase_freq - The frequency of the TCR1 timebase in Hz.
RETURNS NOTES: Error code if channel could not be initialized. Error code that
               can be returned are: FS_ETPU_ERROR_MALLOC , FS_ETPU_ERROR_VALUE.
WARNING      : *This function does not configure the pin only the eTPU. In a
               system a pin may need to be configured to select the eTPU.
******************************************************************************/
int32_t fs_etpu_app_eng_pos_init ( uint8_t cam_channel,
                                   uint8_t cam_priority,
                                   uint8_t cam_edge_polarity,
                                  uint32_t cam_angle_window_start,
                                  uint32_t cam_angle_window_width,
                                   uint8_t crank_channel,
                                   uint8_t crank_priority,
                                   uint8_t crank_edge_polarity,
                                   uint8_t crank_number_of_physical_teeth,
                                   uint8_t crank_number_of_missing_teeth,
                                   uint8_t crank_blank_tooth_count,
                                  uint32_t crank_tcr2_ticks_per_tooth,
                                ufract24_t crank_windowing_ratio_normal,
                                ufract24_t crank_windowing_ratio_after_gap,
                                ufract24_t crank_windowing_ratio_across_gap,
                                ufract24_t crank_windowing_ratio_timeout,
                                ufract24_t crank_gap_ratio,
                                  uint32_t crank_blank_time_ms,
                                  uint32_t crank_first_tooth_timeout_us,
                                  uint32_t crank_link_1,
                                  uint32_t crank_link_2,
                                  uint32_t crank_link_3,
                                  uint32_t crank_link_4,
                                  uint32_t tcr1_timebase_freq                                 
                            )
{
    uint32_t *cam_pba;    /* parameter base address for CAM channel */
    uint32_t *crank_pba;    /* parameter base address for CRANK channel */
    uint32_t cam_angle_window_start_tcr2_count;
    uint32_t cam_angle_window_width_tcr2_count;
     uint8_t *crank_pba8; /* pointer for 8 bit crank variables */
     uint8_t *cam_pba8;  /* pointer for 8 bit crank variables */
    uint32_t *crank_state_ptr;
    uint32_t *crank_cam_state_ptr; /* pointer so CAM can see Crank_State */
    uint32_t tcr2_counts_per_engine_cycle; /* number of tcr2 counts
                                                  in an engine cycle */
    uint32_t crank_blank_time;
    uint32_t crank_first_tooth_timeout;
   
  int32_t error_code = 0; /* returned value from etpu API functions */

  g_crank_channel = crank_channel;
  g_cam_channel = cam_channel;

   /* Disable CAM channel to assign function safely */
   fs_etpu_disable( cam_channel );
   /* Disable CRANK channel to assign function safely */
   fs_etpu_disable( crank_channel );

    if (eTPU->CHAN[cam_channel].CR.B.CPBA == 0 )
    {
       /* get parameter RAM for
       number of parameters passed from eTPU C code */
       cam_pba = fs_etpu_malloc(FS_ETPU_CAM_NUM_PARMS );
         
         if (cam_pba == 0)
       {
          return (FS_ETPU_ERROR_MALLOC);
       }
    }
    else /*set pba to what is in the CR register*/
    {
       cam_pba=fs_etpu_data_ram(cam_channel);
    }
    cam_pba8 = (uint8_t *) cam_pba;


    if (eTPU->CHAN[crank_channel].CR.B.CPBA == 0 )
    {
       /* get parameter RAM for
       number of parameters passed from eTPU C code */
       crank_pba = fs_etpu_malloc(FS_ETPU_CRANK_NUM_PARMS );
         
         if (crank_pba == 0)
       {
          return (FS_ETPU_ERROR_MALLOC);
       }
    }
    else /*set pba to what is in the CR register*/
    {
       crank_pba=fs_etpu_data_ram(crank_channel);
    }
    crank_pba8 = (uint8_t *) crank_pba;
       
   eTPU->CHAN[cam_channel].CR.B.CPBA = (((uint32_t)cam_pba -  fs_etpu_data_ram_start)>>3);
   eTPU->CHAN[crank_channel].CR.B.CPBA = (((uint32_t)crank_pba -  fs_etpu_data_ram_start)>>3);
   
   /* Parameter range chacking */
   
  if (cam_angle_window_start > 72000)
  {
    error_code = FS_ETPU_ERROR_VALUE;
    cam_angle_window_start = 72000;
  }
 
  if (cam_angle_window_width > 72000)
  {
    error_code = FS_ETPU_ERROR_VALUE;
    cam_angle_window_width = 72000;
  }
 
  if (crank_tcr2_ticks_per_tooth > 1024)
  {
    error_code = FS_ETPU_ERROR_VALUE;
    crank_tcr2_ticks_per_tooth = 1024;
  }

  if (crank_windowing_ratio_normal > 0xFFFFFF)
  {
    error_code = FS_ETPU_ERROR_VALUE;
    crank_windowing_ratio_normal = 0xFFFFFF;
  }
 
  if (crank_windowing_ratio_after_gap > 0xFFFFFF)
  {
    error_code = FS_ETPU_ERROR_VALUE;
    crank_windowing_ratio_after_gap = 0xFFFFFF;
  }
 
  if (crank_windowing_ratio_across_gap > 0xFFFFFF)
  {
    error_code = FS_ETPU_ERROR_VALUE;
    crank_windowing_ratio_across_gap = 0xFFFFFF;
  }
 
  if (crank_windowing_ratio_timeout > 0xFFFFFF)
  {
    error_code = FS_ETPU_ERROR_VALUE;
    crank_windowing_ratio_timeout = 0xFFFFFF;
  } 
 
  if (crank_gap_ratio > 0xFFFFFF)
  {
    error_code = FS_ETPU_ERROR_VALUE;
    crank_gap_ratio = 0xFFFFFF;
  }
 
  if (crank_blank_time_ms >  ((long long)0xFFFFFF * 1000 )/(long long)tcr1_timebase_freq)
  {
    error_code = FS_ETPU_ERROR_VALUE;
    crank_blank_time_ms =  ((long long)0xFFFFFF * 1000 )/(long long)tcr1_timebase_freq;
  }

  if (crank_first_tooth_timeout_us >  ((long long)0xFFFFFF * 1000000)/(long long)tcr1_timebase_freq)
  {
    error_code = FS_ETPU_ERROR_VALUE;
    crank_first_tooth_timeout_us =  ((long long)0xFFFFFF * 1000000)/(long long)tcr1_timebase_freq;
  }
                 
 
  /* calculate eTPU function parameters based on API input parameters */
  tcr2_counts_per_engine_cycle = crank_tcr2_ticks_per_tooth * ((crank_number_of_physical_teeth + crank_number_of_missing_teeth) *2);
  cam_angle_window_start_tcr2_count = ((long long)cam_angle_window_start * tcr2_counts_per_engine_cycle)/(long long)72000;
  cam_angle_window_width_tcr2_count = ((long long)cam_angle_window_width * tcr2_counts_per_engine_cycle)/(long long)72000;

    crank_cam_state_ptr = cam_pba
                    -  (uint32_t) ((uint32_t *) ((fs_etpu_data_ram_start) / 4))
                   + (FS_ETPU_CAM_STATE_OFFSET >>2);

   /* write parameters to data memory for CAM */

   *(cam_pba + ((FS_ETPU_CAM_TCR2_COUNTS_PER_ENGINE_CYCLE_OFFSET - 1)>>2)) = tcr2_counts_per_engine_cycle;
   *(cam_pba + ((FS_ETPU_CAM_ANGLE_WINDOW_START_NEW_OFFSET - 1)>>2)) = cam_angle_window_start_tcr2_count;
   *(cam_pba + ((FS_ETPU_CAM_ANGLE_WINDOW_WIDTH_NEW_OFFSET - 1)>>2)) = cam_angle_window_width_tcr2_count;
   *(cam_pba + ((FS_ETPU_CAM_ANGLE_START_COUNT_OFFSET - 1)>>2)) = tcr2_counts_per_engine_cycle;     

   *((uint8_t *)cam_pba + FS_ETPU_CAM_STATE_OFFSET) = (uint8_t)FS_ETPU_CAM_SYNC_SEEK_OR_START_ANGLE;
   *((uint8_t *)cam_pba + FS_ETPU_CAM_ERROR_STATUS_OFFSET) = (uint8_t)FS_ETPU_CAM_NO_ERROR;


   /* write parameters to data memory for CRANK */
  if (crank_number_of_missing_teeth<=3 && crank_number_of_missing_teeth >=1)
  {
     /* create a mask so the eTPUC can quickly write the  TPR.MISSCNT field */
        *(crank_pba + ((FS_ETPU_CRANK_MISSING_TOOTH_COUNT_MASK_OFFSET - 1)>>2)) = crank_number_of_missing_teeth<<13;
  }
  else
  {
    return (FS_ETPU_ERROR_VALUE);
  }
  *(crank_pba + ((FS_ETPU_CRANK_TICKS_PER_TOOTH_OFFSET - 1)>>2)) = crank_tcr2_ticks_per_tooth;     
  *(crank_pba + ((FS_ETPU_CRANK_WINDOWING_RATIO_NORMAL_OFFSET - 1)>>2)) = crank_windowing_ratio_normal;     
  *(crank_pba + ((FS_ETPU_CRANK_WINDOWING_RATIO_AFTER_GAP_OFFSET - 1)>>2)) = crank_windowing_ratio_after_gap;     
  *(crank_pba + ((FS_ETPU_CRANK_WINDOWING_RATIO_ACROSS_GAP_OFFSET - 1)>>2)) = crank_windowing_ratio_across_gap;     
  *(crank_pba + ((FS_ETPU_CRANK_WINDOWING_RATIO_TIMEOUT_OFFSET - 1)>>2)) = crank_windowing_ratio_timeout;     
  *(crank_pba + ((FS_ETPU_CRANK_GAP_RATIO_OFFSET - 1)>>2)) = crank_gap_ratio;     
  *(crank_pba + ((FS_ETPU_CRANK_TICKS_PER_TOOTH_OFFSET - 1)>>2)) = crank_tcr2_ticks_per_tooth;     
  *(crank_pba + ((FS_ETPU_CRANK_CAM_STATE_OFFSET - 1)>>2)) = (uint24_t)crank_cam_state_ptr;
  *(crank_pba + (FS_ETPU_CRANK_LINK_1_OFFSET >>2)) = crank_link_1;
  *(crank_pba + (FS_ETPU_CRANK_LINK_2_OFFSET >>2)) = crank_link_2;
  *(crank_pba + (FS_ETPU_CRANK_LINK_3_OFFSET >>2)) = crank_link_3;
  *(crank_pba + (FS_ETPU_CRANK_LINK_4_OFFSET >>2)) = crank_link_4;

                                    
  crank_blank_time = ((long long) crank_blank_time_ms *  tcr1_timebase_freq)/(long long)1000 ;
  /* crank_blank_time_ms has a maximum value given by:
   ( 0xFFFFFF * 1000) / tcr1_timebase_freq
  */
 
  *(crank_pba + ((FS_ETPU_CRANK_BLANK_TIME_OFFSET - 1)>>2)) = crank_blank_time;     

  crank_first_tooth_timeout = ((long long) crank_first_tooth_timeout_us  * tcr1_timebase_freq) / (long long)1000000;
  /* crank_first_tooth_timeout_us has a maximum value given by:
   ( 0xFFFFFF/tcr1_timebase_freq ) * 1000000
  */
 
  *(crank_pba + ((FS_ETPU_CRANK_FIRST_TOOTH_TIMEOUT_OFFSET - 1)>>2)) = crank_first_tooth_timeout;     
  *(crank_pba + ((FS_ETPU_CRANK_ANGLE_START_COUNT_OFFSET - 1)>>2)) = tcr2_counts_per_engine_cycle;     
                                          
  *((uint8_t *)crank_pba + FS_ETPU_CRANK_PHYSICAL_CRANK_TEETH_OFFSET) = (uint8_t)crank_number_of_physical_teeth;
  *((uint8_t *)crank_pba + FS_ETPU_CRANK_MISSING_TOOTH_COUNT_OFFSET) = (uint8_t)crank_number_of_missing_teeth;
  *((uint8_t *)crank_pba + FS_ETPU_CRANK_BLANK_TOOTH_COUNT_OFFSET) = (uint8_t)crank_blank_tooth_count;
  *((uint8_t *)crank_pba + FS_ETPU_CRANK_ERROR_STATUS_OFFSET) = (uint8_t)FS_ETPU_CRANK_NO_ERROR;
  *((uint8_t *)crank_pba + FS_ETPU_CRANK_STATE_OFFSET) = (uint8_t)FS_ETPU_CRANK_BLANK_TIME;
  *((uint8_t *)crank_pba + FS_ETPU_CRANK_BLANK_TIME_EXPIRED_FLAG_OFFSET) = (uint8_t)0;
                                            

   /* Write to data memory - global variable*/
  fs_etpu_set_global_24(FS_ETPU_ENG_POS_SYNC_STATUS_GLOBAL_OFFSET, FS_ETPU_ENG_POS_SEEK);

   /* write FM (function mode) bits */
   eTPU->CHAN[cam_channel].SCR.R = cam_edge_polarity;
   eTPU->CHAN[crank_channel].SCR.R = crank_edge_polarity;
   
   /* update the TBCR TCR2CTL field according to edge polarity */
   if (crank_edge_polarity == FS_ETPU_CRANK_FM0_RISING_EDGE)
   {
      if (crank_channel <=63) /* engine A */
      {
         eTPU->TBCR_A.B.TCR2CTL = FS_ETPU_TCR2CTL_RISE>>29;
      }
      else /* engine B */
      {         
         eTPU->TBCR_B.B.TCR2CTL = FS_ETPU_TCR2CTL_RISE>>29;
      }
   }
   else /* Falling edge */
   {
      if (crank_channel <=63) /* engine A */
      {
         eTPU->TBCR_A.B.TCR2CTL = FS_ETPU_TCR2CTL_FALL>>29;
      }
      else /* engine B */
      {         
         eTPU->TBCR_B.B.TCR2CTL = FS_ETPU_TCR2CTL_FALL>>29;
      }
   }
   
    /*write hsr*/
    eTPU->CHAN[crank_channel].HSRR.R = FS_ETPU_CRANK_INIT;
    eTPU->CHAN[cam_channel].HSRR.R = FS_ETPU_CAM_INIT;
         
 /* write channel configuration registers */
   eTPU->CHAN[cam_channel].CR.R =
         (cam_priority << 28) +
            (FS_ETPU_CAM_TABLE_SELECT << 24) +
         (FS_ETPU_CAM_FUNCTION_NUMBER << 16) +
         (((uint32_t)cam_pba -  fs_etpu_data_ram_start)>>3);

   eTPU->CHAN[crank_channel].CR.R =
         (crank_priority << 28) +
            (FS_ETPU_CRANK_TABLE_SELECT << 24) +
         (FS_ETPU_CRANK_FUNCTION_NUMBER << 16) +
         (((uint32_t)crank_pba -  fs_etpu_data_ram_start)>>3);
   
   return(error_code);
}
int32_t fs_etpu_eng_update_cam_window(uint32_t cam_angle_window_start,
                                      uint32_t cam_angle_window_width
                                     )
                           
{
  uint32_t cam_angle_window_start_tcr2_count;
  uint32_t cam_angle_window_width_tcr2_count;   
  uint8_t crank_number_of_physical_teeth;
  uint8_t crank_number_of_missing_teeth;
  uint32_t crank_tcr2_ticks_per_tooth;
  uint32_t tcr2_counts_per_engine_cycle;
  int32_t error_code = 0; /* returned value from etpu API functions */

   /* Parameter range chacking */
   
  if (cam_angle_window_start > 72000)
  {
    error_code = FS_ETPU_ERROR_VALUE;
    cam_angle_window_start = 72000;
  }
 
  if (cam_angle_window_width > 72000)
  {
    error_code = FS_ETPU_ERROR_VALUE;
    cam_angle_window_width = 72000;
  }

  crank_number_of_physical_teeth = fs_etpu_get_chan_local_8(g_crank_channel,  FS_ETPU_CRANK_PHYSICAL_CRANK_TEETH_OFFSET);
 
  crank_number_of_missing_teeth = fs_etpu_get_chan_local_8(g_crank_channel,  FS_ETPU_CRANK_MISSING_TOOTH_COUNT_OFFSET);
 
  crank_tcr2_ticks_per_tooth = fs_etpu_get_chan_local_24(g_crank_channel,  FS_ETPU_CRANK_TICKS_PER_TOOTH_OFFSET);

  tcr2_counts_per_engine_cycle = crank_tcr2_ticks_per_tooth * ((crank_number_of_physical_teeth + crank_number_of_missing_teeth) *2);

  cam_angle_window_start_tcr2_count = ((long long)cam_angle_window_start * tcr2_counts_per_engine_cycle)/(long long)72000;
  cam_angle_window_width_tcr2_count = ((long long)cam_angle_window_width * tcr2_counts_per_engine_cycle)/(long long)72000;

   fs_etpu_set_chan_local_24( g_cam_channel, 
                              FS_ETPU_CAM_ANGLE_WINDOW_WIDTH_HOST_OFFSET, 
                                            cam_angle_window_width_tcr2_count);

   fs_etpu_set_chan_local_24( g_cam_channel, 
                              FS_ETPU_CAM_ANGLE_WINDOW_START_HOST_OFFSET, 
                                            cam_angle_window_start_tcr2_count );

   eTPU->CHAN[g_cam_channel].HSRR.R = FS_ETPU_CAM_UPDATE_WINDOW;
                                           
   return(0);
}

/* error handling */
int8_t fs_etpu_eng_pos_get_cam_error_status()
{
   return(fs_etpu_get_chan_local_8( g_cam_channel,
                                    FS_ETPU_CAM_ERROR_STATUS_OFFSET));
}

uint32_t fs_etpu_eng_pos_get_cam_edge_angle()
{
  uint8_t crank_number_of_physical_teeth;
  uint8_t crank_number_of_missing_teeth;
  uint32_t crank_tcr2_ticks_per_tooth;
  uint32_t tcr2_counts_per_engine_cycle;
  uint32_t cam_edge_angle;

  crank_number_of_physical_teeth = fs_etpu_get_chan_local_8(g_crank_channel,  FS_ETPU_CRANK_PHYSICAL_CRANK_TEETH_OFFSET);
 
  crank_number_of_missing_teeth = fs_etpu_get_chan_local_8(g_crank_channel,  FS_ETPU_CRANK_MISSING_TOOTH_COUNT_OFFSET);
 
  crank_tcr2_ticks_per_tooth = fs_etpu_get_chan_local_24(g_crank_channel,  FS_ETPU_CRANK_TICKS_PER_TOOTH_OFFSET);

  tcr2_counts_per_engine_cycle = crank_tcr2_ticks_per_tooth * ((crank_number_of_physical_teeth + crank_number_of_missing_teeth) *2);

  cam_edge_angle = ((long long)fs_etpu_get_chan_local_24( g_cam_channel,
                                    FS_ETPU_CAM_EDGE_ANGLE_OFFSET) * 72000)/(long long)tcr2_counts_per_engine_cycle;


   return(cam_edge_angle);   
}

int8_t fs_etpu_eng_pos_get_crank_error_status()
{
   return(fs_etpu_get_chan_local_8( g_crank_channel,
                                    FS_ETPU_CRANK_ERROR_STATUS_OFFSET));
}

int32_t fs_etpu_eng_pos_clear_cam_error_status()
{
     fs_etpu_set_chan_local_8( g_cam_channel, 
                               FS_ETPU_CAM_ERROR_STATUS_OFFSET, 
                                            FS_ETPU_CAM_NO_ERROR );
    return(0);
}

int32_t fs_etpu_eng_pos_get_engine_cycle_0_tcr2_count()
{
     return(fs_etpu_get_chan_local_24( g_cam_channel, 
                               FS_ETPU_CAM_ENGINE_CYCLE_0_COUNT_OFFSET));
}

int32_t fs_etpu_eng_pos_clear_crank_error_status()
{
  fs_etpu_set_chan_local_8( g_crank_channel, 
                             FS_ETPU_CRANK_ERROR_STATUS_OFFSET, 
                                          FS_ETPU_CRANK_NO_ERROR );
    return(0);
}

int8_t fs_etpu_eng_pos_get_cam_status()
{
      return(fs_etpu_get_chan_local_8( g_cam_channel,
                                       FS_ETPU_CAM_STATE_OFFSET));
}

int8_t fs_etpu_eng_pos_get_crank_status()
{
   return(fs_etpu_get_chan_local_8( g_crank_channel,
                                    FS_ETPU_CRANK_STATE_OFFSET));
}

int8_t fs_etpu_eng_pos_get_engine_position_status()
{
      return(fs_etpu_get_global_24(FS_ETPU_ENG_POS_SYNC_STATUS_GLOBAL_OFFSET));
}

int8_t fs_etpu_eng_pos_get_tooth_number()
{
   return(fs_etpu_get_chan_local_8( g_crank_channel,
                                    FS_ETPU_CRANK_TOOTH_COUNT_OFFSET));
}

int32_t fs_etpu_eng_pos_set_tooth_number (uint8_t tooth_number )
{
  fs_etpu_set_chan_local_8( g_crank_channel, 
                             FS_ETPU_CRANK_TOOTH_COUNT_OFFSET, 
                                          tooth_number );
  return(0);
}

int32_t fs_etpu_eng_pos_get_tooth_time()
{
   return(fs_etpu_get_chan_local_24( g_crank_channel,
                                     FS_ETPU_CRANK_TOOTH_TIME_OFFSET));
}
int32_t fs_etpu_eng_pos_get_engine_speed(uint32_t tcr1_timebase_freq)
{
  vuint8_t crank_number_of_physical_teeth;
  vuint8_t crank_number_of_missing_teeth;
  vuint32_t crank_tooth_period;
  vuint32_t speed_rpm;

  crank_number_of_physical_teeth = fs_etpu_get_chan_local_8(g_crank_channel,  FS_ETPU_CRANK_PHYSICAL_CRANK_TEETH_OFFSET);
  crank_number_of_missing_teeth = fs_etpu_get_chan_local_8(g_crank_channel,  FS_ETPU_CRANK_MISSING_TOOTH_COUNT_OFFSET);
  crank_tooth_period = fs_etpu_get_chan_local_24(g_crank_channel,  FS_ETPU_CRANK_TOOTH_PERIOD_A_OFFSET);

  speed_rpm = (tcr1_timebase_freq * 60) /((crank_number_of_physical_teeth+crank_number_of_missing_teeth)*crank_tooth_period) ;
 
  return(speed_rpm);   
}


int32_t fs_etpu_eng_pos_set_wr_normal (ufract24_t ratio )
{
  int32_t error_code = 0; /* returned value from etpu API functions */

  if (ratio > 0xFFFFFF)
  {
    error_code = FS_ETPU_ERROR_VALUE;
    ratio = 0xFFFFFF;
  }
  fs_etpu_set_chan_local_24( g_crank_channel, 
                              FS_ETPU_CRANK_WINDOWING_RATIO_NORMAL_OFFSET, 
                                           ratio );
  return(error_code);
}

int32_t fs_etpu_eng_pos_set_wr_after_gap (ufract24_t ratio )
{
  int32_t error_code = 0; /* returned value from etpu API functions */

  if (ratio > 0xFFFFFF)
  {
    error_code = FS_ETPU_ERROR_VALUE;
    ratio = 0xFFFFFF;
  }
  fs_etpu_set_chan_local_24( g_crank_channel, 
                              FS_ETPU_CRANK_WINDOWING_RATIO_AFTER_GAP_OFFSET, 
                                           ratio );
  return(error_code);
}

int32_t fs_etpu_eng_pos_set_wr_across_gap (ufract24_t ratio )
{
  int32_t error_code = 0; /* returned value from etpu API functions */

  if (ratio > 0xFFFFFF)
  {
    error_code = FS_ETPU_ERROR_VALUE;
    ratio = 0xFFFFFF;
  }
  fs_etpu_set_chan_local_24( g_crank_channel, 
                              FS_ETPU_CRANK_WINDOWING_RATIO_ACROSS_GAP_OFFSET, 
                                           ratio );
  return(error_code);
}

int32_t fs_etpu_eng_pos_set_wr_timeout (ufract24_t ratio )
{
  int32_t error_code = 0; /* returned value from etpu API functions */

  if (ratio > 0xFFFFFF)
  {
    error_code = FS_ETPU_ERROR_VALUE;
    ratio = 0xFFFFFF;
  }
  fs_etpu_set_chan_local_24( g_crank_channel, 
                              FS_ETPU_CRANK_WINDOWING_RATIO_TIMEOUT_OFFSET, 
                                           ratio );
  return(error_code);
}

int32_t fs_etpu_eng_pos_insert_tooth(uint8_t host_asserted_tooth_count)
{
   fs_etpu_set_chan_local_8( g_crank_channel,
                             FS_ETPU_CRANK_HOST_ASSERTED_TOOTH_COUNT_OFFSET,
                             host_asserted_tooth_count );

  fs_etpu_set_hsr( g_crank_channel,  FS_ETPU_CRANK_IPH);
  return(0);   
}

int32_t fs_etpu_eng_pos_adjust_angle (int24_t angle_adjust )
{
  fs_etpu_set_chan_local_24( g_crank_channel, 
                              FS_ETPU_CRANK_SIGNED_ANGLE_ADJUST_OFFSET, 
                                         angle_adjust );
  fs_etpu_set_hsr( g_crank_channel,  FS_ETPU_CRANK_ANGLE_ADJUST);
  return(0);   
}


Code: Select all

/**************************************************************************
 * FILE NAME: $RCSfile: etpu_app_eng_pos.h,v $                       *
 *                                           COPYRIGHT (c) FREESCALE 2007 *
 * DESCRIPTION:                                     All Rights Reserved   *
 * This file contains the prototypes and defines for the eTPU automotive  *
 * synchronisation functions.                                             *
 *========================================================================*
 * ORIGINAL AUTHOR: Geoff Emerson (r47354)                                *
 * $Log: etpu_app_eng_pos.h,v $
 * Revision 1.7  2009/01/20 12:45:27  r54529
 * Corrected load calculation for GCT
 *
 * Revision 1.6  2009/01/14 11:08:52  r47354
 * Added load calculation for GCT
 *
 * Revision 1.5  2008/11/26 15:29:36  r47354
 * Add type for parameter in speed API.
 *
 * Revision 1.4  2008/11/13 10:48:57  r47354
 * Added fs_etpu_eng_pos_get_engine_speed function.
 *
 * Revision 1.3  2008/08/28 13:22:50  r47354
 * fs_etpu_eng_pos_insert_tooth now has host_asserted_tooth_count parameter.
 *
 * Revision 1.2  2008/06/06 09:53:27  r47354
 * Major rework based on etpuc code changes and review.
 *
 * Revision 1.1  2008/01/21 13:49:05  r47354
 * Initial revision
 *
 *
 **************************************************************************/
#include "etpu_cam_auto.h"   /* Auto generated header file for eTPU cam   */
#include "etpu_crank_auto.h" /* Auto generated header file for eTPU crank */

/**************************************************************************/
/*                       Function Prototypes                              */
/**************************************************************************/

/* eng_pos channel initialisation */

int32_t fs_etpu_app_eng_pos_init ( uint8_t cam_channel,
                                   uint8_t cam_priority,
                                   uint8_t cam_edge_polarity,
                                  uint32_t cam_angle_window_start,
                                  uint32_t cam_angle_window_width,
                                   uint8_t crank_channel,
                                   uint8_t crank_priority,
                                   uint8_t crank_edge_polarity,
                                   uint8_t crank_number_of_physical_teeth,
                                   uint8_t crank_number_of_missing_teeth,
                                   uint8_t crank_blank_tooth_count,
                                  uint32_t crank_tcr2_ticks_per_tooth,
                                ufract24_t crank_windowing_ratio_normal,
                                ufract24_t crank_windowing_ratio_after_gap,
                                ufract24_t crank_windowing_ratio_across_gap,
                                ufract24_t crank_windowing_ratio_timeout,
                                ufract24_t crank_gap_ratio,
                                  uint32_t crank_blank_time_ms,
                                  uint32_t crank_first_tooth_timeout_us,
                                  uint32_t crank_link_1,
                                  uint32_t crank_link_2,
                                  uint32_t crank_link_3,
                                  uint32_t crank_link_4,
                                  uint32_t tcr1_timebase_freq );

/* read parameter functions */
uint32_t fs_etpu_eng_pos_get_cam_edge_angle();
int8_t fs_etpu_eng_pos_get_tooth_number();
int32_t fs_etpu_eng_pos_get_tooth_time();
int32_t fs_etpu_eng_pos_get_engine_speed(uint32_t tcr1_timebase_freq);

/* read status functions */
int8_t fs_etpu_eng_pos_get_engine_position_status();
int8_t fs_etpu_eng_pos_get_cam_status();
int8_t fs_etpu_eng_pos_get_crank_status();

/* read error status functions */
int8_t fs_etpu_eng_pos_get_cam_error_status();
int8_t fs_etpu_eng_pos_get_crank_error_status();

/* clear error status functions */
int32_t fs_etpu_eng_pos_clear_cam_error_status();
int32_t fs_etpu_eng_pos_clear_crank_error_status();

/* update parameter functions */
int32_t fs_etpu_eng_update_cam_window (uint32_t cam_angle_window_start,
                                       uint32_t cam_angle_window_width);
                                       
/* set windowing ratio functions */
int32_t fs_etpu_eng_pos_set_wr_normal( ufract24_t ratio );
int32_t fs_etpu_eng_pos_set_wr_after_gap( ufract24_t ratio );
int32_t fs_etpu_eng_pos_set_wr_across_gap( ufract24_t ratio );
int32_t fs_etpu_eng_pos_set_wr_timeout( ufract24_t ratio );

/* advanced functions */
int32_t fs_etpu_eng_pos_insert_tooth( uint8_t host_asserted_tooth_count );
int32_t fs_etpu_eng_pos_adjust_angle( int24_t angle_adjust );

/* debug functions */
int32_t fs_etpu_eng_pos_get_engine_cycle_0_tcr2_count();
int32_t fs_etpu_eng_pos_set_tooth_number ( uint8_t tooth_number );

/**************************************************************************
*        Information for eTPU Graphical Configuration Tool
***************************************************************************/
/* eTPU functions used: CAM, CRANK */
/* full function name: Engine Position (CAM and CRANK channels) */
/* channel assignment; load: eng_pos
   CAM = cam_channel; priority=cam_priority
   CRANK = crank_channel; priority=crank_priority
*/
/* load expression eng_pos
var engine_speed { 0..20000 } [ rpm ]
 
rev_360_base = 100*(engine_speed/60)/etpu_clock_freq
rev_720_base = rev_360_base/2 

CAM = (65)*rev_720_base
CRANK = (136 + (crank_number_of_physical_teeth - 2)*118 + 154)*rev_360_base
*/


Well I think you get the idea... As mentioned not that bad.

jafrey
Posts: 33
Joined: Tue Nov 05, 2013 12:15 am

Re: eTPU interface & Precompiled binaries for ST SPC56xx?

Postby jafrey » Mon May 26, 2014 11:12 pm

Did you purchase a compiler?

Nobody
Posts: 8
Joined: Wed May 14, 2014 3:17 am

Re: eTPU interface & Precompiled binaries for ST SPC56xx?

Postby Nobody » Tue May 27, 2014 10:12 pm

First - hope Giovanni doesn’t mind me posting Freescale related info? If so I’ll stop.

No, I did not purchase TPU compiler. You can get a 30 day evaluation and they (Freescale) may give you free extension license. That being said, I do have the compiler, but with what is offered as compiled functions covers my current needs.

There are 2-3 free or close enough to free tools that will generate initialization code for TPU and misc peripherals (i.e. DMA). The example I posted was done with “eTPU Graphical Configuration Tool”, it’s straight forward and intuitive.

As was mentioned “Engine TPU function set 1” has you covered up to 6 cylinders. Other sets get you 8, which are also free. There are limitations though, the single biggest one is crank tooth patterns, it will not support a GM (General Motors) style crank which is a specialized absolute type (for this you will need a TPU compiler). Since GM introduced this on LS1 many manufacturers have followed suit, due to fast starting, it does not require 1-2 complete engine revolutions to synchronize and start injector and coil operation.

I think your best bet is spend a bunch of time on Freescale site and read up. I was surprised how quickly a simple simulated engine could be coded, although this was using all Freescale tools (Code Warrior). Have not had a chance to test with SPC5 studio compiler.

I'd search for following;
* AN2897
* AN3769
* AN3770
* AN3771
* AN3772

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: eTPU interface & Precompiled binaries for ST SPC56xx?

Postby Giovanni » Wed May 28, 2014 8:20 am

It is not a problem, this site is not ST-related, just the port has been provided by ST.

Giovanni


Return to “SPC56x Support”

Who is online

Users browsing this forum: No registered users and 9 guests