Hi,
I need the two halves of timer A to run at the same frequency (2.5MHz @ CPU clock = 120MHz) but with a certain phase shift between them.
The code below is in theory what is needed but the execution time can vary if code AFTER it changes - I suspect this is due to pipelining etc.
TimerEnable(TIMER0_BASE, TIMER_B);
__nop();
__nop();
__nop();
__nop();
__nop();
__nop();
__nop();
__nop();
__nop();
__nop();
__nop();
__nop();
TimerEnable(TIMER0_BASE, TIMER_A);
The __delay_cycles intrinsic, another option, carries the warning:
Note: Cycle timing is based on 0 wait states.
Results vary with additional wait states. The
implementation does not account for dynamic
prediction. Lower delay cycle counts may be
less accurate given pipeline flush behaviors.
- and behaved the same when tested.
I am aware of an instruction "ISB" that will flush the pipeline. Can you please recommend how this can be used in this instance, or any other way of getting the required delay accurately and independent of surrounding code changes? This code only needs to run once, at system startup.
Thank you,
Matthew