sonnybalut
Posts: 6
Joined: Fri Apr 17, 2015 2:57 am

pigpio script problem

Sat Apr 18, 2015 1:56 am

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
pigs pigiov

Also on pigpio website under pigs how many bits are params and vars for virtual machine.

Thanks,
Sonny

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: pigpio script problem

Sat Apr 18, 2015 6:02 am

I am assuming you are referencing pigs:

http://abyz.co.uk/rpi/pigpio/pigs.html

You might try sending an email to pigpio @ abyz.co.uk
marcus
:ugeek:

User avatar
joan
Posts: 14996
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: pigpio script problem

Sat Apr 18, 2015 7:18 am

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
pigs pigiov

Also on pigpio website under pigs how many bits are params and vars for virtual machine.

Thanks,
Sonny
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.

sonnybalut
Posts: 6
Joined: Fri Apr 17, 2015 2:57 am

Re: pigpio script problem

Sat Apr 18, 2015 4:43 pm

Thank you for the response, I assume accumulator works similar to assembly language. But everything works fine now.

Sonny

Return to “Beginners”