2010/8/24 vasile surducan <[email protected]>

> So the frequency is a dword counted in hertz?


Yes


> Meaning if we need 29KHz we do  pwm_set_frequency (29_000) ?
>

Yes


> It doesn't work for me even with prescaler 1 at 40Mhz and PR2 register
> =0xFF it should work up to 39KHz
>

But did you manually set prescaler and PR2 register ? By "not working", do
you mean the resulting frequency isn't 29KHz ?


>
> The second problem (and is quite a problem) is the length of a small code:
>
> pwm_max_resolution(1)
> pwm_set_frequency(29000)
> pwm1_set_dutycycle_highres(512)
> pwm1_on()
>
> is eating around 800 bytes...
>

Yes, this is called "beauty" :)

I guess dword is killing some bytes while computing frequency parameters
(have you tried to dig this in order to know where bytes are eaten ?). I
guess another procedure where frequency is a constant (assuming you don't
need variable frequency) could be added:

    const dword PWM_FREQUENCY = 29_000
    include pwm_hardware
    ...
    pwm_max_resolution(1)
    -- pwm_set_frequency(29000) ; not needed anymore
    pwm1_set_dutycycle_highres(512)
    pwm1_on()


Somewhere in pwm libs:

if defined(PWM_FREQUENCY) then
   -- user (probably Vasile) needs a constant frequency)
   -- => setup freq params as in pwm_set_frequency but this time using
   -- a constant.
end if


Cheers,
Seb



>
> Vasile
>
>
> On Mon, Aug 23, 2010 at 1:02 PM, Sebastien Lelong <
> [email protected]> wrote:
>
>> Hi Vasile,
>>
>> Maybe "pwm_set_frequency(dword in freq)", in pwm_common.jal ?
>> See:
>> http://justanotherlanguage.org/content/jallib/tutorials/tutorial_pwm2
>>
>> Cheers,
>> Seb
>>
>> 2010/8/23 vasile surducan <[email protected]>
>>
>>>  Hi all,
>>>
>>> In the current pwm library (pwm_common.jal, pwm_hardware.jal,
>>> pwm_ccpx.jal) the pwm frequency can be set exactly (in terms of KHz) ?
>>>
>>> thx,
>>> Vasile
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "jallib" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<jallib%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/jallib?hl=en.
>>>
>>
>>
>>
>> --
>> Sébastien Lelong
>> http://www.sirloon.net
>> http://sirbot.org
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "jallib" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<jallib%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/jallib?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "jallib" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<jallib%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/jallib?hl=en.
>



-- 
Sébastien Lelong
http://www.sirloon.net
http://sirbot.org

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to