2189270_en-US

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

2189270_en-US

2189270_en-US

eTPU crank, cam, injections and Ignitions on S32K3

Hello,

I need to implement drivers to actuate Injections and ignitions phased with crank and cam signals.

I need to understand which is the best solution to implement this drivers.

My doubt are:

1) The API provided by AN4907SW.zip are compatible with eTPU present in S32K3xx?

2)If no, it's a good solution adapt this API for S32K3xx or the best solution it's use ConfigTool ?


There is an example for S32K3xx about this application?

Regards, Francesco.


Re: eTPU crank, cam, injections and Ignitions on S32K3

Hi @francescovico 

Converting data from big-endian to little-endian involves reversing the byte order by adjusting bit shifts and masks according to the data type size.

GCC provides built-in functions to simplify this process, for example: uint32_t __builtin_bswap32 (uint32_t x). You can find more details in the GCC documentation: 7.2.3 Byte-Swapping Builtins

Re: eTPU crank, cam, injections and Ignitions on S32K3

Hi @VaneB ,

if I understood well , the Automotive functions (CRANK, SPARK...), are made for big endian microcontrollers.

To use eTPU with Automotive functions on S32K364 (little endian), I need to download a function set selecting :

francescovico_0-1761136257258.png

And change the functions:

uint32_t *fs_memcpy32(uint32_t *dest,uint32_t *source,uint32_t size);
void fs_memset32(uint32_t *start,uint32_t value,int32_t size);

to swap each 32 bit values to read/write little endian code and parameters, it's true?

Regards, Francesco.





Re: eTPU crank, cam, injections and Ignitions on S32K3

Hi @francescovico 

The S32K39/37/36 Microcontrollers for Electrification Applications, includes eTPU. However, there is currently no dedicated documentation or demo similar to the MPC5634's AN4907 available for these devices.

That said, the AN4907 document, demo, and microcode are suitable for the S32K39/37/36 family, but please note that these devices use a little-endian architecture. Therefore, you will need to modify the memory access API.

You can refer to the motor control-related modules in the CodeWarrior eTPU Function Selector, which has been updated to little-endian.


BR, VaneB

Re: eTPU crank, cam, injections and Ignitions on S32K3

Thanks for pointing this out!
There was an endianity conversion issue. As a result, the missing tooth mask was not configured correctly and it counted 350 deg per rev resp 700 deg per cycle.
Now, the demo app in the original post is fixed.

Re: eTPU crank, cam, injections and Ignitions on S32K3

Hi @MilanBrejl ,

Now I'm trying to use Fuel Cyl 1 etpu driver.

It seem that  the driver use s24AngleNormalEnd as "start angle" and stop all injections at s24AngleStop.

The duration u24InjectionTime it's never respected.

It's possible?

Attached there is a .rar file that contain  picoscope acquisition of "fuel cyl 1" where the injector parameter are:

Etpu_Fuel_Ip_ConfigType fuel_1_config =
{
.s24AngleNormalEnd = DEG2TCR2(-180),
.s24AngleStop = DEG2TCR2(-360),
.s24AngleOffsetRecalc = DEG2TCR2(-30),
.u24InjectionTime = USEC2TCR1(1200),
.u24CompensationTime = USEC2TCR1(0),
.u24InjectionTimeMinimum = USEC2TCR1(0),
.u24OffTimeMinimum = USEC2TCR1(0),
.eGenerationDisable = ETPU_FUEL_GENERATION_ALLOWED
};

In the picoscope acquisition it's visible start of injection exactly at 180° , stop of injection at 360° and injection duration of 30 ms (it should be 1,2ms).

Regards, Francesco.

Re: eTPU crank, cam, injections and Ignitions on S32K3

Hi @MilanBrejl  ,

Now I'm trying to use Fuel Cyl 1 etpu driver.

It seem that  the driver use s24AngleNormalEnd as "start angle" and stop injection ever at s24AngleStop.

The duration u24InjectionTime it's never respected.

It's possible?

Attached there is a .rar file that contain  picoscope acquisition of "fuel cyl 1" where the injector parameter are:
Etpu_Fuel_Ip_ConfigType fuel_1_config =
{
.s24AngleNormalEnd = DEG2TCR2(-180),
.s24AngleStop = DEG2TCR2(-360),
.s24AngleOffsetRecalc = DEG2TCR2(-30),
.u24InjectionTime = USEC2TCR1(1200),
.u24CompensationTime = USEC2TCR1(0),
.u24InjectionTimeMinimum = USEC2TCR1(0),
.u24OffTimeMinimum = USEC2TCR1(0),
.eGenerationDisable = ETPU_FUEL_GENERATION_ALLOWED
};

In the picoscope acquisition it's visible start of injection exactly at 180° , stop of injection at 360° and injection duration of 30 ms (it should be 1,2ms).

Regards, Francesco.

Re: eTPU crank, cam, injections and Ignitions on S32K3

Hi @MilanBrejl ,

You are right, the s24AngleOffsetRecalc must be a positive number, but putting:

s24AngleOffsetRecalc = DEG2TCR2(30)

The result it's the same (.

I'm using S32K364 that have 2 ETPU (A and B) with 16 channels.

Using fuel driver on ETPUA the driver work correctly, but I need to use ETPUB channel 0.

My necessity it's to share TCR1 and TCR2 from ETPUA to ETPUB, using STAC registers.

It's possible that STAC registers are not correctly initialized?

Regards, Francesco.

Re: eTPU crank, cam, injections and Ignitions on S32K3

Hi @francescovico,

this is how to configure STAC_ENG1 and STAC_ENG2 registers to share TCR1 and TCR2 from eTPU1 to eTPU2:

MilanBrejl_0-1770199430269.png

Let me know if it helps. 


Regards,
Milan

Re: eTPU crank, cam, injections and Ignitions on S32K3

Hi @MilanBrejl ,

my registers are exactly the same of your suggestion:

ETPU_A_B_REGISTER.png

But the problem it's still present.

In the attached picoscope acquisition you can see the spark generated with ETPU A in BLU and spark generated with ETPU B in RED.

Both sparks have end angle 180 degree and dwell time 8000 us.

Regards, Francesco.

Re: eTPU crank, cam, injections and Ignitions on S32K3

Hi @francescovico,

I duplicated your issue on my site and found the root cause. It is not enough to share TCR1/TCR2 time/angle buses between both eTPU engines. Spark and Fuel functions do time to angle transformation, based on the actual engine speed. It uses TRR (Tick Rate Register). This register is part of the Angle Clock logic and it is maintained by Crank eTPU function, running on eTPU A. Hence, TRR has the correct value on eTPU A only. Then, time to angle transformation on eTPU B, using eTPU B TRR, returns a wrong result.

This is pretty fundamental, I probably never met anybody running engine control over both eTPU engines and hence this has not been solved. And especially with the new S32K3 devices limited to 16+16 channels this becomes important. Thanks for bringing up this use-case and thanks for your patience.

The attached demo application is based on the previous one (in this thread) and adds the following changes:

  1. Spark 2 channel is moved from eTPU engine A to eTPU engine B
    MilanBrejl_0-1770672522362.png
  2. Channel masks are updated accordingly
    MilanBrejl_1-1770672675064.png
  3. Channel links need to support usage of both engines (use macro ETPU_IP_CHANNEL_TO_LINK)
    MilanBrejl_2-1770672729220.png
  4. pin configuration is updated, interrupt configuration updated

    And now new features of Crank eTPU FW:
  5. eTPU FW image is updated. The Crank function can run on both engines and update the TRR value also for the other eTPU engine. 
  6. This new feature requires to set one new parameter to the Crank configuration
    MilanBrejl_4-1770673143063.png

    where
    MilanBrejl_3-1770673103441.png


I hope this helps. 

Regards,
Milan

Re: eTPU crank, cam, injections and Ignitions on S32K3

Hi @MilanBrejl ,

Now It's working perfectly.

Thank you very much for the support!

Regards, Francesco.

Re: eTPU crank, cam, injections and Ignitions on S32K3

Hello, I'm also researching the K396 board and want to use ETPU for crankshaft, camshaft, and oil injectors. Could we discuss this further?

Tags (1)
No ratings
Version history
Last update:
a week ago
Updated by: