Assuming the following code:
while(1) {
Siul2_Dio_Ip_WritePin(DEBUG_1_PORT, DEBUG_1_PIN, 0);
Siul2_Dio_Ip_WritePin(DEBUG_1_PORT, DEBUG_1_PIN, 1);
}Stepping into the Siul RTD drivers:
void Siul2_Dio_Ip_WritePin(... args ...) {
...
empty asserts
...
/* LOCK code */
SchM_Enter_Dio_DIO_EXCLUSIVE_AREA_01();
/* End LOCK code
/* REGISTER SET code
Siul2_Dio_Ip_PinsChannelType pinsValues = (Siul2_Dio_Ip_PinsChannelType)base->PGPDO;
pinsValues &= (Siul2_Dio_Ip_PinsChannelType)(~((Siul2_Dio_Ip_PinsChannelType)1U << (15U - pin)));
pinsValues |= (Siul2_Dio_Ip_PinsChannelType)(((Siul2_Dio_Ip_PinsChannelType)value & 1U) << (15U - pin));
base->PGPDO = pinsValues;
/* End REGISTER SET code
/* UNLOCK code */
SchM_Exit_Dio_DIO_EXCLUSIVE_AREA_01();
/* End UNLOCK code */
}
I split into 3 sections, LOCK + REGISTER SET + UNLOCK, if I list the operations done during REGISTER SET:
- 1 x memory read
- 2 x substractions
- 2 x bit shift
- 4 x logic operations
- 1 x memory write
Using a Cortex M7 (S32K311) I assume one cycle per operation will take aprox 10 cycles, at 120MHz core clock == 83ns (correct me if I'm wrong).
So I assume that most of that 2us time I see comes from the LOCK/UNLOCK sections.
Can I remove theLOCK/UNLOCK sections from RTD assuming the code is as simple as shown above?