Sebastien Lelong wrote:

[RobH]
>> 1. in pwm_ccp1.jal
>>
>>> procedure pwm1_set_dutycycle(byte in duty) is
>>>    ccpr1l_shadow = duty
>>>    CCPR1L  = ccpr1l_shadow   -- reload 8 high order bits of dutycycle
>>>    CCP1CON = ccp1con_shadow  -- reload 2 low  order bits of dutycycle
>>> end procedure
>> When setting low resolution mode I think the 2 low order bits of the 10
>> for the duty cycle should be explicitly set to '00'.  True or false?
> 
> 
>>From what I can understand, ccp1con_shadow is init to 0, and then never
> changed when using low resolution.

True, but there is something else with the meaning / implementation of 
high/low resolution in the pwm libs, for which I'll open a new issue.

>> 2. Setting PWM in high resolution mode activates PWM, same with
>> percent_dutycycle. Why not when setting PWM in low resolution mode?
>> Seems more consistent to let these procedures all active PWM.
> 
> 
> Yes, it seems.

OK, will be done then!
I'm also considering to add 'pin_CCPx_direction = output' when 
activating pwm (and don't touch it with  pwm_off()). This as service to 
the user who may easily forget it. Will be documented with pwm_on()!


> 
>> 3. in pwm_ccp1.jal
>>
>>> procedure pwm1_off() is
>>>    -- pwm mode off, but keep 2 LSbits values
>>>    ccp1con_shadow = ccp1con_shadow & !0b_0000_1100
>>>    CCP1CON = ccp1con_shadow
>>> end procedure
>> This leaves the CCP module in some Capture/Compare mode state (bits 0
>> and 1 could be any value). I assume it is very unlikely that someone
>> 'hot' switches the CCP module alternately for PWM and Capture/Compare
>> mode.  Therefore I think it would be better to switch off the whole CCP
>> module with:
>>    ccp1con_shadow = ccp1con_shadow & !0b_0000_1111
>>
>>
> Sorry, I don't see what you mean. DS says "11xx", so it should be ok with
> current version, right ? Is it a "be explicit" issue ?

Setting with 0b1100 is no problem. I thought resetting with !1100 would 
be a problem because the 2 low order bits are not reset to 00. But since 
a shadow register is used which is supposed not to be touched by the 
user these bits remain always 00 and need not be reset.
BTW I think I'll use register subfields for the CCPCONx_shadow, which 
will 'solve' the problem and will improve readability (my opinion!).

Before committing anything I'll be in touch for a code review!

Thanks Rob.


-- 
Rob Hamerling, Vianen, NL (http://www.robh.nl/)

--~--~---------~--~----~------------~-------~--~----~
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