Hi,
We used CCS Version: 5.4.0.00091 and HalCoGen 3.0.6.
We have successfully initialized the edge interrupts and want to control enable and disable edge0, edge1 and e.t.c. interrupts separately during the program.
How can we do this?
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.
Hi,
We used CCS Version: 5.4.0.00091 and HalCoGen 3.0.6.
We have successfully initialized the edge interrupts and want to control enable and disable edge0, edge1 and e.t.c. interrupts separately during the program.
How can we do this?
Roman,
In theory this should be as simple as writing some code to do:
void edgeInterruptEnable(uint32 edge)
{
hetRAM->Instruction[(edge+17U)].Control |= 0x00000001U;
}
void edgeInterruptDisable(uint32 edge)
{
hetRAM->Instruction[(edge+17U)].Control &= ~(0x00000001U);
}
However, in practice this would not be a robust solution because you are doing a R-M-W of the control field, and the 'PRV' bit in the control field is used in the edge-detect function itself. So if an edge occurred between the read and the write back involved in the |= or the &=, you might corrupt the PRV bit.
To make this work, you need to write your own HET code. You could either add another instruction that's only job is to trigger the interrupt, and branch around this when the edge isn't detected.
While you could use the MOV64 instruction like the PWM does, to update the control field, this would get tricky as you'd need one that writes PRV=1 and the other PRV=0; and you'd have to toggle between them.
I'd probably start with the 'extra instruction' and use a "BR" with event = NOCOND to implement this.
Then you can safely toggle bit 0 of the control field of that instructions, since there's no history kept in the control field of a BR (that's important in this case.... when event = NOCOND... BR also has "PRV" but that is used for the pin 'RISE, FALL, BOTH" conditions...).
So that's a complicated answer - but what you need to do if you want your program to be robust.
If you can tolerate some corruption of edge detection near the places where you enable/disable interrupts, then you could try the asynchronous method with the RMW hazard...
NOTE: the TMS570 NHET and N2HET changed the implementation of edge detect and no longer uses the PRV bit in the control field for this purpose; it keeps an internal edge detect for each pin. Subtle difference, but you can see where it's an improvement/simplification.