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;