sonnybalut wrote:I can't blink gpio4 using acc but ok with var or param, I also tried parse and no error
this should blink led hooked-up to gpio 3 times but instead blinks forever, runs ok if I substitute var or params and use correct decrement for var or params
pigs proc lda 3 tag 999 w 4 0 mils 300 w 4 1 mils 300 dcra jnz 999
pigs hwver -> 3
Also on pigpio website under pigs how many bits are params and vars for virtual machine.
The accumulator A is used for the status of commands. So it will be overwritten by the result of the w (write) and mils (delay milliseconds) commands which can all fail if they are passed the wrong parameter. Given that they succeed A will end up with a value 0 each time around the loop so DCRA will always be -1.
One solution is to push/pop the accumulator.
pigs proc lda 3 tag 999 pusha w 4 0 mils 300 w 4 1 mils 300 popa dcra jnz 999
All the parameters and vars are 32 bit quantities.
The code is the definitive documentation. pthScript in pigpio.c.