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.

TMS570LC4357: Interrupt clearing: how to ensure write to peripheral interrupt flag register is completed before re-enabling IRQs in CPSR?

Part Number: TMS570LC4357

Hi,

When clearing a peripheral interrupt (e.g. RTI Compare interrupt, cleared through RTIINTFLAG register), how can it be ensured that the write to the memory-mapped register was indeed completed and that the flag was cleared, before continuing? This write completeness needs to be ensured in the case of an interrupt handler where the IRQs are re-enabled (by clearing the I-bit in the CPSR) after clearing the interrupt flag: if the I-bit is cleared before the write to the interrupt flag has been completed, this will result in the interrupt being caught again.

Is there a standard/recommended way to ensure completeness of writes on peripheral registers and if so, where would that be documented?

Thank you,

Antoine

  • Antoine,

    Generally speaking, our mechanism to insure a write has completed is to perform a read back of the register to compare to the expected written value/result of the write. In the case of an interrupt flag, this could be problematic since there is always the case where another interrupt hits immediately after or concurrently with the clearing of the flag. i.e., the repeated interrupt is a real event instead of failed write. But, if we consider that the re-enable of the interrupts in the CPSR, this shouldn't happen as they are independent tasks/writes.
  • Chuck,

    Thank you for your answer. Could you tell me where this mechanism is documented? We would like to have a document to refer to in our standards.
  • Hi,

    I would like to follow up on this issue. Again, would it be possible to know what TI documentation specifies that performing a read back of the register to compare to the expected written value/result of the write insures that the write has completed? Having a document to refer to is important for justification and maintainability purposes.

    Thank you for your help,
    Antoine
  • Antoine,

    This safety mechanism is documented in both our Safety Manuals as well as our FMEDA. The FMEDA is provided as part of the Detailed Safety Analysis Report package in the SafeTI Private E2E.

    If we also note that you are using the TMS570LC4357 which has Cache memory, you should be sure you are reading the peripheral and not a cached value. If this is done, it is inherently true that a read back will demonstrate that the write has completed because the read access after the write returns the modified/updated value.
  • I neglected to provide the link to the Safety  Manual for the LC4357 device. It is located at this link: 

  • Hi,

    I think you are refering to §7.118 "Software Read Back of Written Configuration" in the Safety Manual. However, our concern is not safety here. It is pure functional. We are not trying to mitigate HW failures, but simply do the appropriate sequence of operations so that the CPU correctly clears interrupt bits before we re-enable core interrupts (IRQ).

    1) We have found some documentation saying how to proceed, but we have questions on it. ARM Cortex-R5 TRM, Appendix D "Memory Ordering" says that since all the accesses to peripherals go through the same port (peripheral bus), reading the same control register as just written will guarantee completion of the write before the read. That seems great. But it only applies if we configure the region as Device. It does not say the behavior if configured as Strongly Ordered. Is that appendix also applicable if Strongly Ordered is used?

    2) Also, the key for ordering seems to be that all accesses go through the same port. However, there are two ports towards the peripherals: AXI Peripheral interface and Virtual AXI Peripheral interface. By default, the virtual is disabled. But do you confirm that if we would have enabled the virtual interface, we would lose the ordering property between read and writes? (e.g. if the write when through one port and the read through the other...) This makes me realize I don't know what tells through which port an access will go... Could you tell us if the Virtual port is available on the TMS570LC and if so, what is the value of its base address? (Peripheral interface region registers BaseAddress field for LLPP Virtual AXI)

    Thanks.
  • Hello Etienne,

    I think you are refering to §7.118 "Software Read Back of Written Configuration" in the Safety Manual. However, our concern is not safety here. It is pure functional. We are not trying to mitigate HW failures, but simply do the appropriate sequence of operations so that the CPU correctly clears interrupt bits before we re-enable core interrupts (IRQ).

    You are correct. This is described within the context of being a safety mechanism but more widely it is to insure that the write has completed successfully. The reason for a different value being read back could be a number of reasons including the flag not being cleared yet. Given the sequencing and the fact that the read will be held until the write is completed, the most likely cause of a mismatch would be either a new interrupt occurrence or a stuck bit, though.

    1) We have found some documentation saying how to proceed, but we have questions on it. ARM Cortex-R5 TRM, Appendix D "Memory Ordering" says that since all the accesses to peripherals go through the same port (peripheral bus), reading the same control register as just written will guarantee completion of the write before the read. That seems great. But it only applies if we configure the region as Device. It does not say the behavior if configured as Strongly Ordered. Is that appendix also applicable if Strongly Ordered is used?

    Certainly the description indicates a positive behavior with respect to your objectives. However, I cannot infer that this section also applies to Strongly Ordered memory types. This is something only ARM can answer directly.

    However, the following from section 7.2 in the ARM Cortex-R5F TRM indicates a similar attribute to the statements in reference to Device type memory. All access will occur in program order.

    2) Also, the key for ordering seems to be that all accesses go through the same port. However, there are two ports towards the peripherals: AXI Peripheral interface and Virtual AXI Peripheral interface. By default, the virtual is disabled. But do you confirm that if we would have enabled the virtual interface, we would lose the ordering property between read and writes? (e.g. if the write when through one port and the read through the other...) This makes me realize I don't know what tells through which port an access will go... Could you tell us if the Virtual port is available on the TMS570LC and if so, what is the value of its base address? (Peripheral interface region registers BaseAddress field for LLPP Virtual AXI)

    We do not implement the Virtual AXI Peripheral Interface Port. We only have the standard AXI Peripheral Interface Port so there is no concern over having two paths for access.

  • Chuck Davenport said:

    Certainly the description indicates a positive behavior with respect to your objectives. However, I cannot infer that this section also applies to Strongly Ordered memory types. This is something only ARM can answer directly.

    I think your post answers the question. However, to make sure things are clear and that we are free of using Device or Strongly Ordered, could you ask ARM about this and if true, that they clarify the documentation to say that Appendix D is also applicable in Strongly Ordered? As a end user, we do not have a support contract with them ... but I guess TI has one as a customer.

    Thanks.

  • Etienne,

    I don't believe there is a need for further confirmation with ARM. The statements highlighted above are very clear that both Device Type and Strongly Ordered accesses execute in program sequence. As you have noted it states this in Appendix D for Device Type and, as I noted, in table 7-2 for Strongly Ordered. However, I will make a post on the ARM support forum to see if they can make a clarification.

    Also note that the support forum for ARM is public and there is no requirement for a support contract with them.
  • Etienne,

    I retract my statement about the support with ARM. I am actually uncertain if they have a direct access forum like TI does. I recall now that we use an email to their support group for support but I don't know if there is effectively any filtering that occurs based on customer email domain. Nonetheless, I will send them this query.