ETPU - HSR when Match Service (FUEL and SPARK)

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

ETPU - HSR when Match Service (FUEL and SPARK)

Jump to solution
1,061 Views
mertk
Contributor IV

Hi all,

I am currently working on eTPU - AN4907 Engine Control demo. In the etpuc_fuel.c (FUEL function), there is two thread (UPDATE_0 and UPDATE_1) in order to refresh and drive the injection signal with respect to latest value of injection_time and injection_end_angle. 

I am struggle to understand how the red circled code works? (See below)

mertk_0-1668409374926.png

 

I used to simulate and run this section of code in ASH WARE eTPU2+ Development Tool. Unfortunately, I couldn't achieve to run this section whatever I do.  I added extra junk while loop to extend the time being MRLA is set in order to send HSR while MRLA is set.  

 

mertk_1-1668409864401.png

Here is the what happens: UPDATE_1 thread is waiting the PULSE_START thread to be serviced. So, when UPDATE_1 thread is servicing, the MRLA is already clear. Thus red circled code (if part) is not working. Is it normal? If it is not working (maybe we can say that for it is a dead code?) why we are putting this if part into UPDATE_0 and UPDATE_1 threads?

Note: Same desing exists in SPARK functions also  

mertk_3-1668410238156.png

Best regards,

Mert.

0 Kudos
1 Solution
1,022 Views
johndiener
Contributor IV

Hello Mert,

Your first statement is correct. The second part is not. When SchedulePulseEnd runs as part of the UPDATE_0 HSR thread processing, it clears MRLA and sets the pulse end match (and sets flag0 to indicate injection active). This effectively "cancels" the PULSE_START service that would have happened without the "higher priority" HSR coming in.  The next service will be for PULSE_END (or another HSR).

Best regards,

-john

 

 

John Diener

View solution in original post

0 Kudos
5 Replies
1,041 Views
johndiener
Contributor IV

Hello Mert,

This case(s) you are referencing can occur when another channel/thread is being serviced when a FUEL pulse starts/ends, AND the host CPU issues an update HSR to this FUEL channel just after the FUEL pin transition occurs:

ThreadPic_pulse_end_case.png

This situation causes the code in the "if (cc.MRLA)" clause to run:

Update_1_code.png

I am able to get this situation to occur in simulation by causing another thread to run at the just the right time (in this case a SPARK update thread):

script_file.png

The same can be done on a FUEL pulse start.

Best regards,

-john

 

John Diener
1,031 Views
mertk
Contributor IV

Hi John,

Thanks for the answer. ETPU will run the "if part" of UPDATE_0 thread when HSR comes between PULSE_START edge and PULSE_START service. In the "if part" of the UPDATE_0 thread, SchedulePulseEnd function will run and it will schedule the PULSE_END. However after this UPDATE_0 thread end, PULSE_START thread will be service which is interruptted because of HSR and it will also re-schedule the PULSE_END. Therefore, the "if part" of the UPDATE_0 has no meaning because it will be owerwritten by the PULSE_START service. Are my findings correct?

Best Regards,

Mert.

0 Kudos
1,023 Views
johndiener
Contributor IV

Hello Mert,

Your first statement is correct. The second part is not. When SchedulePulseEnd runs as part of the UPDATE_0 HSR thread processing, it clears MRLA and sets the pulse end match (and sets flag0 to indicate injection active). This effectively "cancels" the PULSE_START service that would have happened without the "higher priority" HSR coming in.  The next service will be for PULSE_END (or another HSR).

Best regards,

-john

 

 

John Diener
0 Kudos
1,054 Views
mertk
Contributor IV

Hi,

I forgot to specify that, normally the comments in the UPDATE_0 thread says us "Theoretically, the HSR_UPDATE can be serviced between PULSE_START edge and PULSE_START service - check match A latch."  I understand that, when cpu send HSR to etpu at the start of the injection pulse, UPDATE_0 thread must be run because flag0 is not set to FUEL_FLAG0_INJ_ACTIVE yet. However, due to the HSR not interrupting the actively running PULSE_START thread, flag0 value is set to FUEL_FLAG0_INJ_ACTIVE. Thus, instead of UPDATE_0, UPDATE_1 is running! 

mertk_0-1668413324067.png

 

 

0 Kudos
1,053 Views
mertk
Contributor IV

Hi all  

"Theoretically, the HSR_UPDATE can be serviced between PULSE_START edge and PULSE_START service - check match A latch." Could be this comment considering the situations like below image? .d

How can I test this code, while it's take only 0.020 microsecond? What happens, if I don't want to run if part of the UPDATE_0 (UPDATE_0 will be run but the if part of the UPDATE_0 will not be run)? Is the PULSE_START will be run after UPDATE_0?

mertk_0-1668413977939.png

Best regards,

Mert.

 

0 Kudos