Set sample rate from pi4j API #294
Replies: 5 comments 6 replies
-
|
When I run your code I see PIGPIO ERROR: PI_HPWM_ILLEGAL; illegal: return PWM in use for main clock But I believe for the same reason as you observed your error, Initialize attempted twice. Maybe you already debugged this to see that Pi4J.newAutoContext(); results in all/any providers being created thus calling initialize on the Pigpio provider. Your creating a Pigpio provider instance prior to this broke the normal steps. Answer, I do not see a means to accomplish this without modification of the Pi4j code base, and I am not suggesting that be done. I will list two of the Pi4j leads to allow their input/suggestions. @eitch @FDelporte |
Beta Was this translation helpful? Give feedback.
-
|
hi, good remark @taartspi about the newAutoContext. So we are discussing that problem separately :-) @msawicki-poland without testing the code myself, so there could still be errors, I would like to propose the following structure. Maybe also try-catches to be added for easier debugging? |
Beta Was this translation helpful? Give feedback.
-
|
For the null exception var pi4j = Pi4J.newAutoContext(); remove var, so the class' pi4j variable is set. Then you will hit the next problem exception PWM clock in use. To fix this pigpio.gpioCfgClock(2, 1, 0); // leave clock using the PCM set the second parm to 1, then the PCM remains the clock (it was the default clock prior to this method call) I can see the LED very dimly on, from reading specs and posts I am not certain what is the actual max frequency you may obtain. |
Beta Was this translation helpful? Give feedback.
-
|
Did you resolve this ? If not I would be interested to see added try/catches to print the stacktrace. I am curious what is different that this simple program behaves differently your machine versus mine. |
Beta Was this translation helpful? Give feedback.
-
|
You made a major change between discussion #293 and this entry #294. You changed from pwm software to hardware timing. #2 In this discussion code, the example code you supplied does not require the method initPiGpio. The function gpioCfgClock pertain to only software PWM. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I implemented simple app like this:
and when I run it I got error PI_INITIALISED; function called after gpioInitialise.
How to fix it so I can set sample rate from Java?
Beta Was this translation helpful? Give feedback.
All reactions