Code: Select all
const debugPin as byte = J.1
putpin debugPin, 0
do
pulseout debugPin, 1E-5, 1
sleep 0.001
loop
Anyone have thoughts? Most likely this is something silly I'm doing wrong...
Code: Select all
const debugPin as byte = J.1
putpin debugPin, 0
do
pulseout debugPin, 1E-5, 1
sleep 0.001
loop
I copied your code verbatim and placed in inside Sub Main() ... End Sub. Running it produces a pulse 10.2uS long beginning approximately every 46 uS.pjc30943 wrote:The following fails to produce pulses on a 1280n.
dkinzer wrote:I copied your code verbatim and placed in inside Sub Main() ... End Sub. Running it produces a pulse 10.2uS long beginning approximately every 46 uS.pjc30943 wrote:The following fails to produce pulses on a 1280n.
Can you duplicate that as a simple test case?
Code: Select all
'~~~~~~~~~~~~ PWM ~~~~~~~~~~~~~~
'based on TMR4 (PWM)
OpenPWM motor1PWMCh, SERVO_REFRESH_RATE, zxCorrectPWM 'set up for RC control
PWM motor1PWMch, SERVO_PWM_CENTER_PERCENT
PWM servo1PWMch, SERVO_PWM_CENTER_PERCENT '0.0625
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Code: Select all
public const motor1PWMch as byte = 7 'ch8 PWM, L.4, based on timer 4
public const servo1PWMch as byte = 8 'ch7 PWM, L.3
Code: Select all
dim testVar as single
testVar = 1.0 / 1E5
pulseout debugPin, testVar, 1
'pulseout debugPin, 1.0 / 1E5, 1
Code: Select all
'dim testVar as single
'testVar = 1.0 / 1E5
'pulseout debugPin, testVar, 1
pulseout debugPin, 1.0 / 1E5, 1
No. On a ZX-1280 or ZX-1280n the timer used for I/O functions like PulseOut() is Timer4. This information is found in the Resource Usage section of the System Library Reference. The I/O timer is indicated in the column of the table with the heading I/O.pjc30943 wrote:Doesn't pulseOut() use TMR2?
Code: Select all
Option TargetCPU zx1280n
public const debugPin as byte = J.1
public bvars as single
Sub Main()
putpin debugPin, zxOutputLow
bvars = 2E-5
do
'pulseout debugPin, 2E-5, 1
pulseout debugPin, bvars, 1
sleep 0.002
loop
End Sub
Code: Select all
Option TargetCPU zx1280n
public const debugPin as byte = J.1
public bvars as single
Sub Main()
putpin debugPin, zxOutputLow
bvars = 2E-5
do
pulseout debugPin, 2E-5, 1
'pulseout debugPin, bvars, 1
sleep 0.002
loop
End Sub
We were able to reproduce the problem and have identified both the cause and the solution. It is an issue with native mode code generation for PulseOut() when it has type Single, non-constant value for the duration parameter. The compiler correctly deduces that in this particular case the value of bvars might change over the iterations of the loop since it is a public variable and could be modified by another task.pjc30943 wrote:This example does not produce pulses
Code: Select all
Option TargetCPU zx1280n
public const debugPin as byte = J.1
public bvars as single
Sub Main()
putpin debugPin, zxOutputLow
bvars = 2E-5
Dim duration as Single
duration = bvars
do
pulseout debugPin, duration, 1
sleep 0.002
loop
End Sub