This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LS3137: Port Direction registers are overwritten during initialization of PWM and ICU

Part Number: TMS570LS3137

In AUTOSAR_MCAL_TMS570LSx-05.30.00, Direction register is overwritten in below scenarios

Scenario1

The Direction Register of N2HET1 having UserConfiguration from Port_Init is overwritten after PWM_Init

Details:
In the Port_Config for PortPinN2Het1_25
InitialPortMode = DIO
Direction = OUTPUT
For PIN_V5_37
Pin_Mux = ALT_1
DIR Regsiter values after Port_Init -- > 0x02400202

After the Call to PWM_init, it is automatically set to Input.
DIR register after PWM_Init is --> 0x0000FFFF

I see the below code extract (Pwm_Het_Init) doing this.
HET_PRY(RegBaseAddress) = 0x0000FFFFU; /* Channels 0 to 15 are priority level 1, 16 to 31 priority level 2 */
HET_PFR(RegBaseAddress) = 0x00000700U;
HET_CGR(RegBaseAddress) = 0x00030001U;
HET_PDR(RegBaseAddress) = 0x00U;
HET_PULLDIS(RegBaseAddress) = 0xFFFF0000U;
HET_PSL(RegBaseAddress) = 0xFFFF0000U;
HET_DIR(RegBaseAddress) = 0x0000FFFFU;

• Please explain the reason for hardcoding the direction register thereby ignoring the Port user configuration. From my understanding the registers should be written from the user configured values and not some hardcoded/magic numbers.

It is not allowed as per AUTOSAR to overwrite the user configuration.

 Scenario 2

Same as  PWM_Init, the Icu_Init also changes or overwrites the DIR register. It is not acceptable to use the Port_SetDirection() as a workaround as the Direction was already set in the Port module. Please work on removing this overwriting of the registers in the ICU_Init too.

Additional Query

What is the significance of hardcoding below registers for PWM and ICU?

HET_PRY(RegBaseAddress) = 0x0000FFFFU; /* Channels 0 to 15 are priority level 1, 16 to 31 priority level 2 */
HET_PFR(RegBaseAddress) = 0x00000700U;
HET_CGR(RegBaseAddress) = 0x00030001U;
HET_PDR(RegBaseAddress) = 0x00U;
HET_PULLDIS(RegBaseAddress) = 0xFFFF0000U;
HET_PSL(RegBaseAddress) = 0xFFFF0000U;

  • Hi Prathibha,

    HET code is performing configuration for NHETx[0-15] for PWM and NHETx[16-31] for ICU. Since all INIT api's are called once once, can you call Port_Init after PWM_Init and ICU_Init?
  • Hello Vishwanath,

    The recommended sequence of Initialisation of the drivers as suggested by the Specification of ECU State Manager is as below, that is Port_Init before the PWM_Init and the ICU_Init. This is what is currently followed.

    However, the document itself mentions that although this is the recommended sequence, others are possible also. If we choose this alternate possibility, MCAL delivery has to ensure the following 

    • MCAL release notes has to mention what is the recommended Init sequence.
    • And Ensure that Port_Init does not overwrite the configured values of PWM_Init, Icu_Init() or other driver Inits done before.
    • Is it recommended to do the PWM_Init, ICU_Init before the PIN Mux is configured in the Port_Init()?

    Can this be ensured and recommended sequence documented in the MCAL release notes or user guides.

    Regards

    Niveditha

  • Hi Niveditha,

    The suggestion was a workaround. We will take this change request and enter into our internal bug tracking tool.