[Lazarus] PWM on raspberry pi

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Mon Mar 7 20:11:54 CET 2016

Koenraad Lelong wrote:
> Hi,
> I'm trying to configure a PWM-pin on the raspberry pi 2. I'm using 
> pigpio, with the demo-program.
> I configured pin 12 (GPIO 18) to be a PWM pin.
> When I click the PWM-button on the demo-program, the pi hangs. I have to 
> power-cycle to "recover".
> I modified this:
>   REG_GPIO = $3F000;
> and this :
>  fd := fpopen('/dev/gpiomem', O_RdWr or O_Sync); // Open the master 
> /dev/memory device
> I'm trying to debug this :
>       delayNanoseconds(200); <-- breakpoint
>       pwmf := Pointer(LongWord(Self.FPwm)+PWM0_RANGE);
>       pwmf^ := $400 ;                             //max: 1023
>       delayNanoseconds(200);
>       pwmf := Pointer(LongWord(Self.FPwm)+PWM1_RANGE);
>       pwmf^ := $400 ;                             //max: 1023
>       delayNanoseconds(200);
> Stepping further with F8.
> When I press F8 on the first
>       pwmf^ := $400;
> the code "singe steps" automatically, but after a number of steps the 
> application crashes and the pi hangs.
> This is different from normally running the application where the 
> application just hangs after pressing the PWM-button.
> Input and output works fine, as user "pi".

Two things: first, Bo on 8th Oct mentioned that he'd had to modify 
pigpio.pas to make it compatible with the RPi2. Second, how are you 
physically driving the system, my experience is that remote access can 
be less reliable than using the directly connected screen and keyboard 
particularly when single-stepping.

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the Lazarus mailing list