[resolved][puzzle] missing piece, The
kuroneko
Posts: 3,623
Below is some code doing C3's SPI selection using a clkfreq/2 counter. arg0 is the required ID (0..7).
DAT spi_set add :jmp, arg0 ' prime call movi outa, #0 ' reset decoder movi outa, #|< (SPI_SEL_CLR - 23) :jmp jmpret $, $+1 wc ' call sub function spi_set_ret long 0-0, s1, s2, s3, s45, s45|NEGX, s67, s67|NEGX s1 movi phsb, #%00000000_0 ' 1 pulse movi phsb, #%10000000_0 jmp spi_set_ret s2 movi frqb, #%10000000_0 ' 2 pulses movi frqb, #%00000000_0 jmp spi_set_ret s3 movi frqb, #%10000000_0 ' 3 pulses [COLOR="red"]???[/COLOR] jmp spi_set_ret s67 movi frqb, #%10000000_0 ' 6/7 pulses s45 movi frqb, #%10000000_0 ' 4/5 pulses if_c waitpne $, #0 movi frqb, #%00000000_0 jmp spi_set_ret CON SPI_SEL_CLK = 8 SPI_SEL_CLR = 25The counter setup is as follows:
DAT movs ctrb, #SPI_SEL_CLK ' clock pin movi ctrb, #%0_00100_000 ' NCO movi phsb, #%10000000_0 ' preset (high)Question: What is the missing instruction?
Comments
But then, you wouldn't need the following jmp, would you.
-Phil
Edit: Oh, wait; that gives four pulses. Hmmm.
The test will succeed since 0 anded with INA will never equal FRQB, and forcing the result to be written will plonk that 0 in FRQB, hopefully 6 cycles
after the previous instruction wrote FRQB.
$8000_0000 + $8000_0000 == 0.
-Phil
-Phil
-Phil