pwm



It allows Lua to use the PWM blocks on the target CPU.


[pwm.setup](pwm.setup( id, frequency, Active Cycle )       Data = pwm.setup( id, frequency, duty ): sets the PWM block 'id' to generate the specified frequency with the specified duty cycle (duty is an integer number from 0 to 100, specifying the duty cycle in percents). It returns the actual frequency set on the PWM block.


Here there is a bigger change on the proposal.

The Timer Clock and the PWM "frame" frequency would be set up in the same function (.setup)

The normal control function would only set the active cicle (.setcycle)

The original .setup function would then be replaced by:


[pwm.setup( id, tmrclock, pwm_frequency ) ]

[pwm.setcycle( id, active_cycle )]

[pwm.start()]   pwm.start( id ): start the PWM block 'id'.

[pwm.stop()]    pwm.stop( id ): stop the PWM block 'id'.


Data = pwm.setclock( id, clock ): set the base clock of the PWM block 'id' to

the given clock. In returns the actual clock set on the PWM block.


[pwm.getclock] Data = pwm.getclock( id ): returns the base clock of the PWM block 'id'.


Is it really necessary to have .getclock ?? The clock is set by the same program, is seldom changed during operation, ..........

If really needed, it could be something like pwm.gettimerclock(id) or something (must be discussed.....)