Instruction Timing
Neighborhood Physicist
Posts: 32
I am working on I2C assembly code to communicate at 400 kHz.· I would like to get the timing down.
When you execute a line of assemby code to change the value of a pin, how soon after (or during) the 4 cycles does the pin flip and at what speed?
Is this true for setting direction as well?
Thanks.
When you execute a line of assemby code to change the value of a pin, how soon after (or during) the 4 cycles does the pin flip and at what speed?
Is this true for setting direction as well?
Thanks.
Comments
Asking "when" makes no sense without a point of reference, i.e. a "WAIT" instruction, or a previous OUTA.
When comparing OUTA instructions it is no help to know details, as they behave identical.
Directly after a WAIT (CNT, PEQ, PNE) an OUTA action should be noticed 62.5 ns after the releasing WAIT event. This can easily be measures with a scope.
I must admit, I never did it .. I shall this evening ....
Be sure to look at the I2C / SPI routines used in FemtoBasic. They're written in assembly and work reliably at 100KHz I2C bus speeds and not reliably at 400KHz (with an 80MHz system clock). They're very general purpose, not just for accessing memory devices, and the generality is probably what's interfering with their use at the higher bus speed.
Someone had mentioned that they had not seen any I2C assembly examples so I started writing my own. I need the 400 KHz, but I will look at the FemtoBasic code for reference.
It seems to take 7.5 ticks between wait release and observed signal. I guessed wrong above..
This is the most likely timing
Still Wait instruction (ticks counted after rising edge)
tick 0.5 Waiting released; 1/2 Tick for inter-cog sync/ signal acquisition
tick 1.5 Writeback slot
Note that the pipeline is stopped for wait and hub instructions (see Tutorial for examples)
tick 2.5 fetch Opcode
tick 3.5 memorxy slot for writeback when interleaved
tick 4.5 get dest
tick 5.5 get source
tick 6.5 action slot
tick 7.5 writeback
As OUTA is only set during the writeback, the signal can't be observed earlier