Revision: 1265
Author: robhamerling
Date: Sat Aug 29 05:14:16 2009
Log:
  Correcting for uppercase file names


http://code.google.com/p/jallib/source/detail?r=1265

Added:
  /trunk/include/peripheral/pwm/pwm_ccp10.jal
  /trunk/include/peripheral/pwm/pwm_ccp6.jal
  /trunk/include/peripheral/pwm/pwm_ccp7.jal
  /trunk/include/peripheral/pwm/pwm_ccp8.jal
  /trunk/include/peripheral/pwm/pwm_ccp9.jal
Deleted:
  /trunk/include/peripheral/pwm/PWM_CCP10.jal
  /trunk/include/peripheral/pwm/PWM_CCP6.jal
  /trunk/include/peripheral/pwm/PWM_CCP7.jal
  /trunk/include/peripheral/pwm/PWM_CCP8.jal
  /trunk/include/peripheral/pwm/PWM_CCP9.jal

=======================================
--- /dev/null
+++ /trunk/include/peripheral/pwm/pwm_ccp10.jal Sat Aug 29 05:14:16 2009
@@ -0,0 +1,123 @@
+--  
-------------------------------------------------------------------------------------
+-- Title: hardware PWM control, dedicated to module CCP10
+-- Author: Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
+-- Adapted-by: Sebastien Lelong, Rob Hamerling.
+-- Compiler: 2.4l
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the ZLIB license  
(http://www.opensource.org/licenses/zlib-license.html)
+--
+-- Description:
+-- Performs PWM operations on the CCP10 module.
+-- This file is automatically included by pwm_hardware.jal
+-- when the target PIC has a CCP10 module.
+-- --
+-- Notes: 1. This is a heavy refactoring of the original pwm_hardware.jal
+--           (Stef's lib)
+--        2. Partly rewritten for JalV2 version 2.4l and Jallib revision  
1171.
+--           Reduced memory occupation. Added procedure for lowres PWM.
+--  
-------------------------------------------------------------------------------------
+
+var byte  _ccpr10l_shadow  = 0                            -- 8 MSbits of  
duty cycle
+var byte  _ccp10con_shadow = 0b0000_0000                  -- shadow
+var bit*2 _ccp10con_shadow_dc10b  at _ccp10con_shadow : 4    -- 2 LSbits  
of duty cycle
+var bit*4 _ccp10con_shadow_ccp10m at _ccp10con_shadow : 0    -- mode  
pattern
+
+
+-- PWM mode on
+-- Restore duty cycle from shadow registers
+-- Note: pin_CCP10_direction should be set to output!
+procedure pwm10_on() is
+
+   _ccp10con_shadow_ccp10m = 0b1100                    -- set PWM mode
+   CCPR10L                = _ccpr10l_shadow            -- restore duty  
cycle
+   CCP10CON               = _ccp10con_shadow           -- activate CCP  
module
+
+end procedure
+
+
+-- PWM mode off
+-- retain duty cycle setting in shadow registers
+procedure pwm10_off() is
+
+   _ccp10con_shadow_ccp10m = 0b0000                    -- set CCP/PWM off
+   CCP10CON               = _ccp10con_shadow
+
+end procedure
+
+
+-- Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
+-- The 'duty' argument is a (max) 10-bits absolute value for the duty  
cycle:
+--  * duty<1:0> are the 2 LSbits
+--  * duty<9:2> are the 8 MSbits
+-- Allowed range: 0..1023
+-- Note: pin_CCP10_direction should be set to output!
+procedure pwm10_set_dutycycle_highres(word in duty) is
+
+   if (duty > 1023) then                            -- upper limit
+      duty = 1023
+   end if
+   _ccpr10l_shadow = byte(duty >> 2)
+   _ccp10con_shadow_dc10b = byte(duty) & 0b11
+
+   pwm10_on()                                        -- activate PWM
+
+end procedure
+
+
+-- Set dutycycle with 8-bits resolution allowing 255 PWM steps.
+-- The 'duty' argument is the 8-bits absolute value for the duty cycle:
+--  * duty<1:0> are the 2 LSbits
+--  * duty<7:2> are the 6 MSbits
+-- Allowed range: 0..255
+-- Beware that steps 256..1023 are not available. In other words
+-- the available PWM range is 25% of the highres procedure.
+-- This procedure is particularly suitable with higher frequencies
+-- whereby the PWM resolution is limited to 256 steps or less!
+procedure pwm10_set_dutycycle_lowres(byte in duty) is
+
+   _ccpr10l_shadow = duty >> 2
+   _ccp10con_shadow_dc10b = duty & 0b11
+
+   pwm10_on()                                        -- activate PWM
+
+end procedure
+
+
+-- Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
+-- This procedure is equivalent to pwm10_set_dutycycle_highres(), but
+-- the low order 2 bits of the 10-bits duty cycle are set to 0.
+-- This means that only every 4th of the available 1023 steps can be  
selected
+-- and consequently max 255 PWM steps are available.
+-- This procedure is for user convenience, allowing to specify an 8 bits
+-- value for the duty cycle is for many applications satisfactory.
+-- Calling this procedure will also activate PWM.
+-- Note: pin_CCP10_direction should be set to output!
+procedure pwm10_set_dutycycle(byte in duty) is
+
+   pwm10_set_dutycycle_highres(word(duty) << 2)
+
+end procedure
+
+
+-- Set a percentage duty cycle, allowing max 100 PWM steps.
+-- Allowed range: 0..100
+-- The duty cycle will be set to the specified percentage of the maximum
+-- for the current PWM frequency.
+-- Note: The number of available PWM steps can be lower than 100 with
+-- (very) high PWM frequencies.
+-- Note: pin_CCP10_direction should be set to output!
+procedure pwm10_set_percent_dutycycle(byte in percent) is
+
+   var word duty
+   if (percent == 0) then
+     duty = 0
+   elsif (percent >= 100) then
+     duty = _pr2_shadow_plus1 - 1
+   else
+     duty = word(percent) * (_pr2_shadow_plus1 / 4) / 25      -- (factor  
PR2/100)
+   end if
+   pwm10_set_dutycycle_highres(duty << 2)
+
+end procedure
+
=======================================
--- /dev/null
+++ /trunk/include/peripheral/pwm/pwm_ccp6.jal  Sat Aug 29 05:14:16 2009
@@ -0,0 +1,123 @@
+--  
-------------------------------------------------------------------------------------
+-- Title: hardware PWM control, dedicated to module CCP6
+-- Author: Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
+-- Adapted-by: Sebastien Lelong, Rob Hamerling.
+-- Compiler: 2.4l
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the ZLIB license  
(http://www.opensource.org/licenses/zlib-license.html)
+--
+-- Description:
+-- Performs PWM operations on the CCP6 module.
+-- This file is automatically included by pwm_hardware.jal
+-- when the target PIC has a CCP6 module.
+-- --
+-- Notes: 1. This is a heavy refactoring of the original pwm_hardware.jal
+--           (Stef's lib)
+--        2. Partly rewritten for JalV2 version 2.4l and Jallib revision  
1171.
+--           Reduced memory occupation. Added procedure for lowres PWM.
+--  
-------------------------------------------------------------------------------------
+
+var byte  _ccpr6l_shadow  = 0                            -- 8 MSbits of  
duty cycle
+var byte  _ccp6con_shadow = 0b0000_0000                  -- shadow
+var bit*2 _ccp6con_shadow_dc6b  at _ccp6con_shadow : 4    -- 2 LSbits of  
duty cycle
+var bit*4 _ccp6con_shadow_ccp6m at _ccp6con_shadow : 0    -- mode pattern
+
+
+-- PWM mode on
+-- Restore duty cycle from shadow registers
+-- Note: pin_CCP6_direction should be set to output!
+procedure pwm6_on() is
+
+   _ccp6con_shadow_ccp6m = 0b1100                    -- set PWM mode
+   CCPR6L                = _ccpr6l_shadow            -- restore duty cycle
+   CCP6CON               = _ccp6con_shadow           -- activate CCP module
+
+end procedure
+
+
+-- PWM mode off
+-- retain duty cycle setting in shadow registers
+procedure pwm6_off() is
+
+   _ccp6con_shadow_ccp6m = 0b0000                    -- set CCP/PWM off
+   CCP6CON               = _ccp6con_shadow
+
+end procedure
+
+
+-- Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
+-- The 'duty' argument is a (max) 10-bits absolute value for the duty  
cycle:
+--  * duty<1:0> are the 2 LSbits
+--  * duty<9:2> are the 8 MSbits
+-- Allowed range: 0..1023
+-- Note: pin_CCP6_direction should be set to output!
+procedure pwm6_set_dutycycle_highres(word in duty) is
+
+   if (duty > 1023) then                            -- upper limit
+      duty = 1023
+   end if
+   _ccpr6l_shadow = byte(duty >> 2)
+   _ccp6con_shadow_dc6b = byte(duty) & 0b11
+
+   pwm6_on()                                        -- activate PWM
+
+end procedure
+
+
+-- Set dutycycle with 8-bits resolution allowing 255 PWM steps.
+-- The 'duty' argument is the 8-bits absolute value for the duty cycle:
+--  * duty<1:0> are the 2 LSbits
+--  * duty<7:2> are the 6 MSbits
+-- Allowed range: 0..255
+-- Beware that steps 256..1023 are not available. In other words
+-- the available PWM range is 25% of the highres procedure.
+-- This procedure is particularly suitable with higher frequencies
+-- whereby the PWM resolution is limited to 256 steps or less!
+procedure pwm6_set_dutycycle_lowres(byte in duty) is
+
+   _ccpr6l_shadow = duty >> 2
+   _ccp6con_shadow_dc6b = duty & 0b11
+
+   pwm6_on()                                        -- activate PWM
+
+end procedure
+
+
+-- Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
+-- This procedure is equivalent to pwm6_set_dutycycle_highres(), but
+-- the low order 2 bits of the 10-bits duty cycle are set to 0.
+-- This means that only every 4th of the available 1023 steps can be  
selected
+-- and consequently max 255 PWM steps are available.
+-- This procedure is for user convenience, allowing to specify an 8 bits
+-- value for the duty cycle is for many applications satisfactory.
+-- Calling this procedure will also activate PWM.
+-- Note: pin_CCP6_direction should be set to output!
+procedure pwm6_set_dutycycle(byte in duty) is
+
+   pwm6_set_dutycycle_highres(word(duty) << 2)
+
+end procedure
+
+
+-- Set a percentage duty cycle, allowing max 100 PWM steps.
+-- Allowed range: 0..100
+-- The duty cycle will be set to the specified percentage of the maximum
+-- for the current PWM frequency.
+-- Note: The number of available PWM steps can be lower than 100 with
+-- (very) high PWM frequencies.
+-- Note: pin_CCP6_direction should be set to output!
+procedure pwm6_set_percent_dutycycle(byte in percent) is
+
+   var word duty
+   if (percent == 0) then
+     duty = 0
+   elsif (percent >= 100) then
+     duty = _pr2_shadow_plus1 - 1
+   else
+     duty = word(percent) * (_pr2_shadow_plus1 / 4) / 25      -- (factor  
PR2/100)
+   end if
+   pwm6_set_dutycycle_highres(duty << 2)
+
+end procedure
+
=======================================
--- /dev/null
+++ /trunk/include/peripheral/pwm/pwm_ccp7.jal  Sat Aug 29 05:14:16 2009
@@ -0,0 +1,123 @@
+--  
-------------------------------------------------------------------------------------
+-- Title: hardware PWM control, dedicated to module CCP7
+-- Author: Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
+-- Adapted-by: Sebastien Lelong, Rob Hamerling.
+-- Compiler: 2.4l
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the ZLIB license  
(http://www.opensource.org/licenses/zlib-license.html)
+--
+-- Description:
+-- Performs PWM operations on the CCP7 module.
+-- This file is automatically included by pwm_hardware.jal
+-- when the target PIC has a CCP7 module.
+-- --
+-- Notes: 1. This is a heavy refactoring of the original pwm_hardware.jal
+--           (Stef's lib)
+--        2. Partly rewritten for JalV2 version 2.4l and Jallib revision  
1171.
+--           Reduced memory occupation. Added procedure for lowres PWM.
+--  
-------------------------------------------------------------------------------------
+
+var byte  _ccpr7l_shadow  = 0                            -- 8 MSbits of  
duty cycle
+var byte  _ccp7con_shadow = 0b0000_0000                  -- shadow
+var bit*2 _ccp7con_shadow_dc7b  at _ccp7con_shadow : 4    -- 2 LSbits of  
duty cycle
+var bit*4 _ccp7con_shadow_ccp7m at _ccp7con_shadow : 0    -- mode pattern
+
+
+-- PWM mode on
+-- Restore duty cycle from shadow registers
+-- Note: pin_CCP7_direction should be set to output!
+procedure pwm7_on() is
+
+   _ccp7con_shadow_ccp7m = 0b1100                    -- set PWM mode
+   CCPR7L                = _ccpr7l_shadow            -- restore duty cycle
+   CCP7CON               = _ccp7con_shadow           -- activate CCP module
+
+end procedure
+
+
+-- PWM mode off
+-- retain duty cycle setting in shadow registers
+procedure pwm7_off() is
+
+   _ccp7con_shadow_ccp7m = 0b0000                    -- set CCP/PWM off
+   CCP7CON               = _ccp7con_shadow
+
+end procedure
+
+
+-- Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
+-- The 'duty' argument is a (max) 10-bits absolute value for the duty  
cycle:
+--  * duty<1:0> are the 2 LSbits
+--  * duty<9:2> are the 8 MSbits
+-- Allowed range: 0..1023
+-- Note: pin_CCP7_direction should be set to output!
+procedure pwm7_set_dutycycle_highres(word in duty) is
+
+   if (duty > 1023) then                            -- upper limit
+      duty = 1023
+   end if
+   _ccpr7l_shadow = byte(duty >> 2)
+   _ccp7con_shadow_dc7b = byte(duty) & 0b11
+
+   pwm7_on()                                        -- activate PWM
+
+end procedure
+
+
+-- Set dutycycle with 8-bits resolution allowing 255 PWM steps.
+-- The 'duty' argument is the 8-bits absolute value for the duty cycle:
+--  * duty<1:0> are the 2 LSbits
+--  * duty<7:2> are the 6 MSbits
+-- Allowed range: 0..255
+-- Beware that steps 256..1023 are not available. In other words
+-- the available PWM range is 25% of the highres procedure.
+-- This procedure is particularly suitable with higher frequencies
+-- whereby the PWM resolution is limited to 256 steps or less!
+procedure pwm7_set_dutycycle_lowres(byte in duty) is
+
+   _ccpr7l_shadow = duty >> 2
+   _ccp7con_shadow_dc7b = duty & 0b11
+
+   pwm7_on()                                        -- activate PWM
+
+end procedure
+
+
+-- Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
+-- This procedure is equivalent to pwm7_set_dutycycle_highres(), but
+-- the low order 2 bits of the 10-bits duty cycle are set to 0.
+-- This means that only every 4th of the available 1023 steps can be  
selected
+-- and consequently max 255 PWM steps are available.
+-- This procedure is for user convenience, allowing to specify an 8 bits
+-- value for the duty cycle is for many applications satisfactory.
+-- Calling this procedure will also activate PWM.
+-- Note: pin_CCP7_direction should be set to output!
+procedure pwm7_set_dutycycle(byte in duty) is
+
+   pwm7_set_dutycycle_highres(word(duty) << 2)
+
+end procedure
+
+
+-- Set a percentage duty cycle, allowing max 100 PWM steps.
+-- Allowed range: 0..100
+-- The duty cycle will be set to the specified percentage of the maximum
+-- for the current PWM frequency.
+-- Note: The number of available PWM steps can be lower than 100 with
+-- (very) high PWM frequencies.
+-- Note: pin_CCP7_direction should be set to output!
+procedure pwm7_set_percent_dutycycle(byte in percent) is
+
+   var word duty
+   if (percent == 0) then
+     duty = 0
+   elsif (percent >= 100) then
+     duty = _pr2_shadow_plus1 - 1
+   else
+     duty = word(percent) * (_pr2_shadow_plus1 / 4) / 25      -- (factor  
PR2/100)
+   end if
+   pwm7_set_dutycycle_highres(duty << 2)
+
+end procedure
+
=======================================
--- /dev/null
+++ /trunk/include/peripheral/pwm/pwm_ccp8.jal  Sat Aug 29 05:14:16 2009
@@ -0,0 +1,123 @@
+--  
-------------------------------------------------------------------------------------
+-- Title: hardware PWM control, dedicated to module CCP8
+-- Author: Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
+-- Adapted-by: Sebastien Lelong, Rob Hamerling.
+-- Compiler: 2.4l
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the ZLIB license  
(http://www.opensource.org/licenses/zlib-license.html)
+--
+-- Description:
+-- Performs PWM operations on the CCP8 module.
+-- This file is automatically included by pwm_hardware.jal
+-- when the target PIC has a CCP8 module.
+-- --
+-- Notes: 1. This is a heavy refactoring of the original pwm_hardware.jal
+--           (Stef's lib)
+--        2. Partly rewritten for JalV2 version 2.4l and Jallib revision  
1171.
+--           Reduced memory occupation. Added procedure for lowres PWM.
+--  
-------------------------------------------------------------------------------------
+
+var byte  _ccpr8l_shadow  = 0                            -- 8 MSbits of  
duty cycle
+var byte  _ccp8con_shadow = 0b0000_0000                  -- shadow
+var bit*2 _ccp8con_shadow_dc8b  at _ccp8con_shadow : 4    -- 2 LSbits of  
duty cycle
+var bit*4 _ccp8con_shadow_ccp8m at _ccp8con_shadow : 0    -- mode pattern
+
+
+-- PWM mode on
+-- Restore duty cycle from shadow registers
+-- Note: pin_CCP8_direction should be set to output!
+procedure pwm8_on() is
+
+   _ccp8con_shadow_ccp8m = 0b1100                    -- set PWM mode
+   CCPR8L                = _ccpr8l_shadow            -- restore duty cycle
+   CCP8CON               = _ccp8con_shadow           -- activate CCP module
+
+end procedure
+
+
+-- PWM mode off
+-- retain duty cycle setting in shadow registers
+procedure pwm8_off() is
+
+   _ccp8con_shadow_ccp8m = 0b0000                    -- set CCP/PWM off
+   CCP8CON               = _ccp8con_shadow
+
+end procedure
+
+
+-- Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
+-- The 'duty' argument is a (max) 10-bits absolute value for the duty  
cycle:
+--  * duty<1:0> are the 2 LSbits
+--  * duty<9:2> are the 8 MSbits
+-- Allowed range: 0..1023
+-- Note: pin_CCP8_direction should be set to output!
+procedure pwm8_set_dutycycle_highres(word in duty) is
+
+   if (duty > 1023) then                            -- upper limit
+      duty = 1023
+   end if
+   _ccpr8l_shadow = byte(duty >> 2)
+   _ccp8con_shadow_dc8b = byte(duty) & 0b11
+
+   pwm8_on()                                        -- activate PWM
+
+end procedure
+
+
+-- Set dutycycle with 8-bits resolution allowing 255 PWM steps.
+-- The 'duty' argument is the 8-bits absolute value for the duty cycle:
+--  * duty<1:0> are the 2 LSbits
+--  * duty<7:2> are the 6 MSbits
+-- Allowed range: 0..255
+-- Beware that steps 256..1023 are not available. In other words
+-- the available PWM range is 25% of the highres procedure.
+-- This procedure is particularly suitable with higher frequencies
+-- whereby the PWM resolution is limited to 256 steps or less!
+procedure pwm8_set_dutycycle_lowres(byte in duty) is
+
+   _ccpr8l_shadow = duty >> 2
+   _ccp8con_shadow_dc8b = duty & 0b11
+
+   pwm8_on()                                        -- activate PWM
+
+end procedure
+
+
+-- Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
+-- This procedure is equivalent to pwm8_set_dutycycle_highres(), but
+-- the low order 2 bits of the 10-bits duty cycle are set to 0.
+-- This means that only every 4th of the available 1023 steps can be  
selected
+-- and consequently max 255 PWM steps are available.
+-- This procedure is for user convenience, allowing to specify an 8 bits
+-- value for the duty cycle is for many applications satisfactory.
+-- Calling this procedure will also activate PWM.
+-- Note: pin_CCP8_direction should be set to output!
+procedure pwm8_set_dutycycle(byte in duty) is
+
+   pwm8_set_dutycycle_highres(word(duty) << 2)
+
+end procedure
+
+
+-- Set a percentage duty cycle, allowing max 100 PWM steps.
+-- Allowed range: 0..100
+-- The duty cycle will be set to the specified percentage of the maximum
+-- for the current PWM frequency.
+-- Note: The number of available PWM steps can be lower than 100 with
+-- (very) high PWM frequencies.
+-- Note: pin_CCP8_direction should be set to output!
+procedure pwm8_set_percent_dutycycle(byte in percent) is
+
+   var word duty
+   if (percent == 0) then
+     duty = 0
+   elsif (percent >= 100) then
+     duty = _pr2_shadow_plus1 - 1
+   else
+     duty = word(percent) * (_pr2_shadow_plus1 / 4) / 25      -- (factor  
PR2/100)
+   end if
+   pwm8_set_dutycycle_highres(duty << 2)
+
+end procedure
+
=======================================
--- /dev/null
+++ /trunk/include/peripheral/pwm/pwm_ccp9.jal  Sat Aug 29 05:14:16 2009
@@ -0,0 +1,123 @@
+--  
-------------------------------------------------------------------------------------
+-- Title: hardware PWM control, dedicated to module CCP9
+-- Author: Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
+-- Adapted-by: Sebastien Lelong, Rob Hamerling.
+-- Compiler: 2.4l
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the ZLIB license  
(http://www.opensource.org/licenses/zlib-license.html)
+--
+-- Description:
+-- Performs PWM operations on the CCP9 module.
+-- This file is automatically included by pwm_hardware.jal
+-- when the target PIC has a CCP9 module.
+-- --
+-- Notes: 1. This is a heavy refactoring of the original pwm_hardware.jal
+--           (Stef's lib)
+--        2. Partly rewritten for JalV2 version 2.4l and Jallib revision  
1171.
+--           Reduced memory occupation. Added procedure for lowres PWM.
+--  
-------------------------------------------------------------------------------------
+
+var byte  _ccpr9l_shadow  = 0                            -- 8 MSbits of  
duty cycle
+var byte  _ccp9con_shadow = 0b0000_0000                  -- shadow
+var bit*2 _ccp9con_shadow_dc9b  at _ccp9con_shadow : 4    -- 2 LSbits of  
duty cycle
+var bit*4 _ccp9con_shadow_ccp9m at _ccp9con_shadow : 0    -- mode pattern
+
+
+-- PWM mode on
+-- Restore duty cycle from shadow registers
+-- Note: pin_CCP9_direction should be set to output!
+procedure pwm9_on() is
+
+   _ccp9con_shadow_ccp9m = 0b1100                    -- set PWM mode
+   CCPR9L                = _ccpr9l_shadow            -- restore duty cycle
+   CCP9CON               = _ccp9con_shadow           -- activate CCP module
+
+end procedure
+
+
+-- PWM mode off
+-- retain duty cycle setting in shadow registers
+procedure pwm9_off() is
+
+   _ccp9con_shadow_ccp9m = 0b0000                    -- set CCP/PWM off
+   CCP9CON               = _ccp9con_shadow
+
+end procedure
+
+
+-- Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
+-- The 'duty' argument is a (max) 10-bits absolute value for the duty  
cycle:
+--  * duty<1:0> are the 2 LSbits
+--  * duty<9:2> are the 8 MSbits
+-- Allowed range: 0..1023
+-- Note: pin_CCP9_direction should be set to output!
+procedure pwm9_set_dutycycle_highres(word in duty) is
+
+   if (duty > 1023) then                            -- upper limit
+      duty = 1023
+   end if
+   _ccpr9l_shadow = byte(duty >> 2)
+   _ccp9con_shadow_dc9b = byte(duty) & 0b11
+
+   pwm9_on()                                        -- activate PWM
+
+end procedure
+
+
+-- Set dutycycle with 8-bits resolution allowing 255 PWM steps.
+-- The 'duty' argument is the 8-bits absolute value for the duty cycle:
+--  * duty<1:0> are the 2 LSbits
+--  * duty<7:2> are the 6 MSbits
+-- Allowed range: 0..255
+-- Beware that steps 256..1023 are not available. In other words
+-- the available PWM range is 25% of the highres procedure.
+-- This procedure is particularly suitable with higher frequencies
+-- whereby the PWM resolution is limited to 256 steps or less!
+procedure pwm9_set_dutycycle_lowres(byte in duty) is
+
+   _ccpr9l_shadow = duty >> 2
+   _ccp9con_shadow_dc9b = duty & 0b11
+
+   pwm9_on()                                        -- activate PWM
+
+end procedure
+
+
+-- Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
+-- This procedure is equivalent to pwm9_set_dutycycle_highres(), but
+-- the low order 2 bits of the 10-bits duty cycle are set to 0.
+-- This means that only every 4th of the available 1023 steps can be  
selected
+-- and consequently max 255 PWM steps are available.
+-- This procedure is for user convenience, allowing to specify an 8 bits
+-- value for the duty cycle is for many applications satisfactory.
+-- Calling this procedure will also activate PWM.
+-- Note: pin_CCP9_direction should be set to output!
+procedure pwm9_set_dutycycle(byte in duty) is
+
+   pwm9_set_dutycycle_highres(word(duty) << 2)
+
+end procedure
+
+
+-- Set a percentage duty cycle, allowing max 100 PWM steps.
+-- Allowed range: 0..100
+-- The duty cycle will be set to the specified percentage of the maximum
+-- for the current PWM frequency.
+-- Note: The number of available PWM steps can be lower than 100 with
+-- (very) high PWM frequencies.
+-- Note: pin_CCP9_direction should be set to output!
+procedure pwm9_set_percent_dutycycle(byte in percent) is
+
+   var word duty
+   if (percent == 0) then
+     duty = 0
+   elsif (percent >= 100) then
+     duty = _pr2_shadow_plus1 - 1
+   else
+     duty = word(percent) * (_pr2_shadow_plus1 / 4) / 25      -- (factor  
PR2/100)
+   end if
+   pwm9_set_dutycycle_highres(duty << 2)
+
+end procedure
+
=======================================
--- /trunk/include/peripheral/pwm/PWM_CCP10.jal Sat Aug 29 03:08:42 2009
+++ /dev/null
@@ -1,123 +0,0 @@
---  
-------------------------------------------------------------------------------------
--- Title: hardware PWM control, dedicated to module CCP10
--- Author: Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
--- Adapted-by: Sebastien Lelong, Rob Hamerling.
--- Compiler: 2.4l
---
--- This file is part of jallib (http://jallib.googlecode.com)
--- Released under the ZLIB license  
(http://www.opensource.org/licenses/zlib-license.html)
---
--- Description:
--- Performs PWM operations on the CCP10 module.
--- This file is automatically included by pwm_hardware.jal
--- when the target PIC has a CCP10 module.
--- --
--- Notes: 1. This is a heavy refactoring of the original pwm_hardware.jal
---           (Stef's lib)
---        2. Partly rewritten for JalV2 version 2.4l and Jallib revision  
1171.
---           Reduced memory occupation. Added procedure for lowres PWM.
---  
-------------------------------------------------------------------------------------
-
-var byte  _ccpr10l_shadow  = 0                            -- 8 MSbits of  
duty cycle
-var byte  _ccp10con_shadow = 0b0000_0000                  -- shadow
-var bit*2 _ccp10con_shadow_dc10b  at _ccp10con_shadow : 4    -- 2 LSbits  
of duty cycle
-var bit*4 _ccp10con_shadow_ccp10m at _ccp10con_shadow : 0    -- mode  
pattern
-
-
--- PWM mode on
--- Restore duty cycle from shadow registers
--- Note: pin_CCP10_direction should be set to output!
-procedure pwm10_on() is
-
-   _ccp10con_shadow_ccp10m = 0b1100                    -- set PWM mode
-   CCPR10L                = _ccpr10l_shadow            -- restore duty  
cycle
-   CCP10CON               = _ccp10con_shadow           -- activate CCP  
module
-
-end procedure
-
-
--- PWM mode off
--- retain duty cycle setting in shadow registers
-procedure pwm10_off() is
-
-   _ccp10con_shadow_ccp10m = 0b0000                    -- set CCP/PWM off
-   CCP10CON               = _ccp10con_shadow
-
-end procedure
-
-
--- Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
--- The 'duty' argument is a (max) 10-bits absolute value for the duty  
cycle:
---  * duty<1:0> are the 2 LSbits
---  * duty<9:2> are the 8 MSbits
--- Allowed range: 0..1023
--- Note: pin_CCP10_direction should be set to output!
-procedure pwm10_set_dutycycle_highres(word in duty) is
-
-   if (duty > 1023) then                            -- upper limit
-      duty = 1023
-   end if
-   _ccpr10l_shadow = byte(duty >> 2)
-   _ccp10con_shadow_dc10b = byte(duty) & 0b11
-
-   pwm10_on()                                        -- activate PWM
-
-end procedure
-
-
--- Set dutycycle with 8-bits resolution allowing 255 PWM steps.
--- The 'duty' argument is the 8-bits absolute value for the duty cycle:
---  * duty<1:0> are the 2 LSbits
---  * duty<7:2> are the 6 MSbits
--- Allowed range: 0..255
--- Beware that steps 256..1023 are not available. In other words
--- the available PWM range is 25% of the highres procedure.
--- This procedure is particularly suitable with higher frequencies
--- whereby the PWM resolution is limited to 256 steps or less!
-procedure pwm10_set_dutycycle_lowres(byte in duty) is
-
-   _ccpr10l_shadow = duty >> 2
-   _ccp10con_shadow_dc10b = duty & 0b11
-
-   pwm10_on()                                        -- activate PWM
-
-end procedure
-
-
--- Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
--- This procedure is equivalent to pwm10_set_dutycycle_highres(), but
--- the low order 2 bits of the 10-bits duty cycle are set to 0.
--- This means that only every 4th of the available 1023 steps can be  
selected
--- and consequently max 255 PWM steps are available.
--- This procedure is for user convenience, allowing to specify an 8 bits
--- value for the duty cycle is for many applications satisfactory.
--- Calling this procedure will also activate PWM.
--- Note: pin_CCP10_direction should be set to output!
-procedure pwm10_set_dutycycle(byte in duty) is
-
-   pwm10_set_dutycycle_highres(word(duty) << 2)
-
-end procedure
-
-
--- Set a percentage duty cycle, allowing max 100 PWM steps.
--- Allowed range: 0..100
--- The duty cycle will be set to the specified percentage of the maximum
--- for the current PWM frequency.
--- Note: The number of available PWM steps can be lower than 100 with
--- (very) high PWM frequencies.
--- Note: pin_CCP10_direction should be set to output!
-procedure pwm10_set_percent_dutycycle(byte in percent) is
-
-   var word duty
-   if (percent == 0) then
-     duty = 0
-   elsif (percent >= 100) then
-     duty = _pr2_shadow_plus1 - 1
-   else
-     duty = word(percent) * (_pr2_shadow_plus1 / 4) / 25      -- (factor  
PR2/100)
-   end if
-   pwm10_set_dutycycle_highres(duty << 2)
-
-end procedure
-
=======================================
--- /trunk/include/peripheral/pwm/PWM_CCP6.jal  Sat Aug 29 03:08:42 2009
+++ /dev/null
@@ -1,123 +0,0 @@
---  
-------------------------------------------------------------------------------------
--- Title: hardware PWM control, dedicated to module CCP6
--- Author: Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
--- Adapted-by: Sebastien Lelong, Rob Hamerling.
--- Compiler: 2.4l
---
--- This file is part of jallib (http://jallib.googlecode.com)
--- Released under the ZLIB license  
(http://www.opensource.org/licenses/zlib-license.html)
---
--- Description:
--- Performs PWM operations on the CCP6 module.
--- This file is automatically included by pwm_hardware.jal
--- when the target PIC has a CCP6 module.
--- --
--- Notes: 1. This is a heavy refactoring of the original pwm_hardware.jal
---           (Stef's lib)
---        2. Partly rewritten for JalV2 version 2.4l and Jallib revision  
1171.
---           Reduced memory occupation. Added procedure for lowres PWM.
---  
-------------------------------------------------------------------------------------
-
-var byte  _ccpr6l_shadow  = 0                            -- 8 MSbits of  
duty cycle
-var byte  _ccp6con_shadow = 0b0000_0000                  -- shadow
-var bit*2 _ccp6con_shadow_dc6b  at _ccp6con_shadow : 4    -- 2 LSbits of  
duty cycle
-var bit*4 _ccp6con_shadow_ccp6m at _ccp6con_shadow : 0    -- mode pattern
-
-
--- PWM mode on
--- Restore duty cycle from shadow registers
--- Note: pin_CCP6_direction should be set to output!
-procedure pwm6_on() is
-
-   _ccp6con_shadow_ccp6m = 0b1100                    -- set PWM mode
-   CCPR6L                = _ccpr6l_shadow            -- restore duty cycle
-   CCP6CON               = _ccp6con_shadow           -- activate CCP module
-
-end procedure
-
-
--- PWM mode off
--- retain duty cycle setting in shadow registers
-procedure pwm6_off() is
-
-   _ccp6con_shadow_ccp6m = 0b0000                    -- set CCP/PWM off
-   CCP6CON               = _ccp6con_shadow
-
-end procedure
-
-
--- Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
--- The 'duty' argument is a (max) 10-bits absolute value for the duty  
cycle:
---  * duty<1:0> are the 2 LSbits
---  * duty<9:2> are the 8 MSbits
--- Allowed range: 0..1023
--- Note: pin_CCP6_direction should be set to output!
-procedure pwm6_set_dutycycle_highres(word in duty) is
-
-   if (duty > 1023) then                            -- upper limit
-      duty = 1023
-   end if
-   _ccpr6l_shadow = byte(duty >> 2)
-   _ccp6con_shadow_dc6b = byte(duty) & 0b11
-
-   pwm6_on()                                        -- activate PWM
-
-end procedure
-
-
--- Set dutycycle with 8-bits resolution allowing 255 PWM steps.
--- The 'duty' argument is the 8-bits absolute value for the duty cycle:
---  * duty<1:0> are the 2 LSbits
---  * duty<7:2> are the 6 MSbits
--- Allowed range: 0..255
--- Beware that steps 256..1023 are not available. In other words
--- the available PWM range is 25% of the highres procedure.
--- This procedure is particularly suitable with higher frequencies
--- whereby the PWM resolution is limited to 256 steps or less!
-procedure pwm6_set_dutycycle_lowres(byte in duty) is
-
-   _ccpr6l_shadow = duty >> 2
-   _ccp6con_shadow_dc6b = duty & 0b11
-
-   pwm6_on()                                        -- activate PWM
-
-end procedure
-
-
--- Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
--- This procedure is equivalent to pwm6_set_dutycycle_highres(), but
--- the low order 2 bits of the 10-bits duty cycle are set to 0.
--- This means that only every 4th of the available 1023 steps can be  
selected
--- and consequently max 255 PWM steps are available.
--- This procedure is for user convenience, allowing to specify an 8 bits
--- value for the duty cycle is for many applications satisfactory.
--- Calling this procedure will also activate PWM.
--- Note: pin_CCP6_direction should be set to output!
-procedure pwm6_set_dutycycle(byte in duty) is
-
-   pwm6_set_dutycycle_highres(word(duty) << 2)
-
-end procedure
-
-
--- Set a percentage duty cycle, allowing max 100 PWM steps.
--- Allowed range: 0..100
--- The duty cycle will be set to the specified percentage of the maximum
--- for the current PWM frequency.
--- Note: The number of available PWM steps can be lower than 100 with
--- (very) high PWM frequencies.
--- Note: pin_CCP6_direction should be set to output!
-procedure pwm6_set_percent_dutycycle(byte in percent) is
-
-   var word duty
-   if (percent == 0) then
-     duty = 0
-   elsif (percent >= 100) then
-     duty = _pr2_shadow_plus1 - 1
-   else
-     duty = word(percent) * (_pr2_shadow_plus1 / 4) / 25      -- (factor  
PR2/100)
-   end if
-   pwm6_set_dutycycle_highres(duty << 2)
-
-end procedure
-
=======================================
--- /trunk/include/peripheral/pwm/PWM_CCP7.jal  Sat Aug 29 03:08:42 2009
+++ /dev/null
@@ -1,123 +0,0 @@
---  
-------------------------------------------------------------------------------------
--- Title: hardware PWM control, dedicated to module CCP7
--- Author: Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
--- Adapted-by: Sebastien Lelong, Rob Hamerling.
--- Compiler: 2.4l
---
--- This file is part of jallib (http://jallib.googlecode.com)
--- Released under the ZLIB license  
(http://www.opensource.org/licenses/zlib-license.html)
---
--- Description:
--- Performs PWM operations on the CCP7 module.
--- This file is automatically included by pwm_hardware.jal
--- when the target PIC has a CCP7 module.
--- --
--- Notes: 1. This is a heavy refactoring of the original pwm_hardware.jal
---           (Stef's lib)
---        2. Partly rewritten for JalV2 version 2.4l and Jallib revision  
1171.
---           Reduced memory occupation. Added procedure for lowres PWM.
---  
-------------------------------------------------------------------------------------
-
-var byte  _ccpr7l_shadow  = 0                            -- 8 MSbits of  
duty cycle
-var byte  _ccp7con_shadow = 0b0000_0000                  -- shadow
-var bit*2 _ccp7con_shadow_dc7b  at _ccp7con_shadow : 4    -- 2 LSbits of  
duty cycle
-var bit*4 _ccp7con_shadow_ccp7m at _ccp7con_shadow : 0    -- mode pattern
-
-
--- PWM mode on
--- Restore duty cycle from shadow registers
--- Note: pin_CCP7_direction should be set to output!
-procedure pwm7_on() is
-
-   _ccp7con_shadow_ccp7m = 0b1100                    -- set PWM mode
-   CCPR7L                = _ccpr7l_shadow            -- restore duty cycle
-   CCP7CON               = _ccp7con_shadow           -- activate CCP module
-
-end procedure
-
-
--- PWM mode off
--- retain duty cycle setting in shadow registers
-procedure pwm7_off() is
-
-   _ccp7con_shadow_ccp7m = 0b0000                    -- set CCP/PWM off
-   CCP7CON               = _ccp7con_shadow
-
-end procedure
-
-
--- Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
--- The 'duty' argument is a (max) 10-bits absolute value for the duty  
cycle:
---  * duty<1:0> are the 2 LSbits
---  * duty<9:2> are the 8 MSbits
--- Allowed range: 0..1023
--- Note: pin_CCP7_direction should be set to output!
-procedure pwm7_set_dutycycle_highres(word in duty) is
-
-   if (duty > 1023) then                            -- upper limit
-      duty = 1023
-   end if
-   _ccpr7l_shadow = byte(duty >> 2)
-   _ccp7con_shadow_dc7b = byte(duty) & 0b11
-
-   pwm7_on()                                        -- activate PWM
-
-end procedure
-
-
--- Set dutycycle with 8-bits resolution allowing 255 PWM steps.
--- The 'duty' argument is the 8-bits absolute value for the duty cycle:
---  * duty<1:0> are the 2 LSbits
---  * duty<7:2> are the 6 MSbits
--- Allowed range: 0..255
--- Beware that steps 256..1023 are not available. In other words
--- the available PWM range is 25% of the highres procedure.
--- This procedure is particularly suitable with higher frequencies
--- whereby the PWM resolution is limited to 256 steps or less!
-procedure pwm7_set_dutycycle_lowres(byte in duty) is
-
-   _ccpr7l_shadow = duty >> 2
-   _ccp7con_shadow_dc7b = duty & 0b11
-
-   pwm7_on()                                        -- activate PWM
-
-end procedure
-
-
--- Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
--- This procedure is equivalent to pwm7_set_dutycycle_highres(), but
--- the low order 2 bits of the 10-bits duty cycle are set to 0.
--- This means that only every 4th of the available 1023 steps can be  
selected
--- and consequently max 255 PWM steps are available.
--- This procedure is for user convenience, allowing to specify an 8 bits
--- value for the duty cycle is for many applications satisfactory.
--- Calling this procedure will also activate PWM.
--- Note: pin_CCP7_direction should be set to output!
-procedure pwm7_set_dutycycle(byte in duty) is
-
-   pwm7_set_dutycycle_highres(word(duty) << 2)
-
-end procedure
-
-
--- Set a percentage duty cycle, allowing max 100 PWM steps.
--- Allowed range: 0..100
--- The duty cycle will be set to the specified percentage of the maximum
--- for the current PWM frequency.
--- Note: The number of available PWM steps can be lower than 100 with
--- (very) high PWM frequencies.
--- Note: pin_CCP7_direction should be set to output!
-procedure pwm7_set_percent_dutycycle(byte in percent) is
-
-   var word duty
-   if (percent == 0) then
-     duty = 0
-   elsif (percent >= 100) then
-     duty = _pr2_shadow_plus1 - 1
-   else
-     duty = word(percent) * (_pr2_shadow_plus1 / 4) / 25      -- (factor  
PR2/100)
-   end if
-   pwm7_set_dutycycle_highres(duty << 2)
-
-end procedure
-
=======================================
--- /trunk/include/peripheral/pwm/PWM_CCP8.jal  Sat Aug 29 03:08:42 2009
+++ /dev/null
@@ -1,123 +0,0 @@
---  
-------------------------------------------------------------------------------------
--- Title: hardware PWM control, dedicated to module CCP8
--- Author: Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
--- Adapted-by: Sebastien Lelong, Rob Hamerling.
--- Compiler: 2.4l
---
--- This file is part of jallib (http://jallib.googlecode.com)
--- Released under the ZLIB license  
(http://www.opensource.org/licenses/zlib-license.html)
---
--- Description:
--- Performs PWM operations on the CCP8 module.
--- This file is automatically included by pwm_hardware.jal
--- when the target PIC has a CCP8 module.
--- --
--- Notes: 1. This is a heavy refactoring of the original pwm_hardware.jal
---           (Stef's lib)
---        2. Partly rewritten for JalV2 version 2.4l and Jallib revision  
1171.
---           Reduced memory occupation. Added procedure for lowres PWM.
---  
-------------------------------------------------------------------------------------
-
-var byte  _ccpr8l_shadow  = 0                            -- 8 MSbits of  
duty cycle
-var byte  _ccp8con_shadow = 0b0000_0000                  -- shadow
-var bit*2 _ccp8con_shadow_dc8b  at _ccp8con_shadow : 4    -- 2 LSbits of  
duty cycle
-var bit*4 _ccp8con_shadow_ccp8m at _ccp8con_shadow : 0    -- mode pattern
-
-
--- PWM mode on
--- Restore duty cycle from shadow registers
--- Note: pin_CCP8_direction should be set to output!
-procedure pwm8_on() is
-
-   _ccp8con_shadow_ccp8m = 0b1100                    -- set PWM mode
-   CCPR8L                = _ccpr8l_shadow            -- restore duty cycle
-   CCP8CON               = _ccp8con_shadow           -- activate CCP module
-
-end procedure
-
-
--- PWM mode off
--- retain duty cycle setting in shadow registers
-procedure pwm8_off() is
-
-   _ccp8con_shadow_ccp8m = 0b0000                    -- set CCP/PWM off
-   CCP8CON               = _ccp8con_shadow
-
-end procedure
-
-
--- Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
--- The 'duty' argument is a (max) 10-bits absolute value for the duty  
cycle:
---  * duty<1:0> are the 2 LSbits
---  * duty<9:2> are the 8 MSbits
--- Allowed range: 0..1023
--- Note: pin_CCP8_direction should be set to output!
-procedure pwm8_set_dutycycle_highres(word in duty) is
-
-   if (duty > 1023) then                            -- upper limit
-      duty = 1023
-   end if
-   _ccpr8l_shadow = byte(duty >> 2)
-   _ccp8con_shadow_dc8b = byte(duty) & 0b11
-
-   pwm8_on()                                        -- activate PWM
-
-end procedure
-
-
--- Set dutycycle with 8-bits resolution allowing 255 PWM steps.
--- The 'duty' argument is the 8-bits absolute value for the duty cycle:
---  * duty<1:0> are the 2 LSbits
---  * duty<7:2> are the 6 MSbits
--- Allowed range: 0..255
--- Beware that steps 256..1023 are not available. In other words
--- the available PWM range is 25% of the highres procedure.
--- This procedure is particularly suitable with higher frequencies
--- whereby the PWM resolution is limited to 256 steps or less!
-procedure pwm8_set_dutycycle_lowres(byte in duty) is
-
-   _ccpr8l_shadow = duty >> 2
-   _ccp8con_shadow_dc8b = duty & 0b11
-
-   pwm8_on()                                        -- activate PWM
-
-end procedure
-
-
--- Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
--- This procedure is equivalent to pwm8_set_dutycycle_highres(), but
--- the low order 2 bits of the 10-bits duty cycle are set to 0.
--- This means that only every 4th of the available 1023 steps can be  
selected
--- and consequently max 255 PWM steps are available.
--- This procedure is for user convenience, allowing to specify an 8 bits
--- value for the duty cycle is for many applications satisfactory.
--- Calling this procedure will also activate PWM.
--- Note: pin_CCP8_direction should be set to output!
-procedure pwm8_set_dutycycle(byte in duty) is
-
-   pwm8_set_dutycycle_highres(word(duty) << 2)
-
-end procedure
-
-
--- Set a percentage duty cycle, allowing max 100 PWM steps.
--- Allowed range: 0..100
--- The duty cycle will be set to the specified percentage of the maximum
--- for the current PWM frequency.
--- Note: The number of available PWM steps can be lower than 100 with
--- (very) high PWM frequencies.
--- Note: pin_CCP8_direction should be set to output!
-procedure pwm8_set_percent_dutycycle(byte in percent) is
-
-   var word duty
-   if (percent == 0) then
-     duty = 0
-   elsif (percent >= 100) then
-     duty = _pr2_shadow_plus1 - 1
-   else
-     duty = word(percent) * (_pr2_shadow_plus1 / 4) / 25      -- (factor  
PR2/100)
-   end if
-   pwm8_set_dutycycle_highres(duty << 2)
-
-end procedure
-
=======================================
--- /trunk/include/peripheral/pwm/PWM_CCP9.jal  Sat Aug 29 03:08:42 2009
+++ /dev/null
@@ -1,123 +0,0 @@
---  
-------------------------------------------------------------------------------------
--- Title: hardware PWM control, dedicated to module CCP9
--- Author: Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
--- Adapted-by: Sebastien Lelong, Rob Hamerling.
--- Compiler: 2.4l
---
--- This file is part of jallib (http://jallib.googlecode.com)
--- Released under the ZLIB license  
(http://www.opensource.org/licenses/zlib-license.html)
---
--- Description:
--- Performs PWM operations on the CCP9 module.
--- This file is automatically included by pwm_hardware.jal
--- when the target PIC has a CCP9 module.
--- --
--- Notes: 1. This is a heavy refactoring of the original pwm_hardware.jal
---           (Stef's lib)
---        2. Partly rewritten for JalV2 version 2.4l and Jallib revision  
1171.
---           Reduced memory occupation. Added procedure for lowres PWM.
---  
-------------------------------------------------------------------------------------
-
-var byte  _ccpr9l_shadow  = 0                            -- 8 MSbits of  
duty cycle
-var byte  _ccp9con_shadow = 0b0000_0000                  -- shadow
-var bit*2 _ccp9con_shadow_dc9b  at _ccp9con_shadow : 4    -- 2 LSbits of  
duty cycle
-var bit*4 _ccp9con_shadow_ccp9m at _ccp9con_shadow : 0    -- mode pattern
-
-
--- PWM mode on
--- Restore duty cycle from shadow registers
--- Note: pin_CCP9_direction should be set to output!
-procedure pwm9_on() is
-
-   _ccp9con_shadow_ccp9m = 0b1100                    -- set PWM mode
-   CCPR9L                = _ccpr9l_shadow            -- restore duty cycle
-   CCP9CON               = _ccp9con_shadow           -- activate CCP module
-
-end procedure
-
-
--- PWM mode off
--- retain duty cycle setting in shadow registers
-procedure pwm9_off() is
-
-   _ccp9con_shadow_ccp9m = 0b0000                    -- set CCP/PWM off
-   CCP9CON               = _ccp9con_shadow
-
-end procedure
-
-
--- Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
--- The 'duty' argument is a (max) 10-bits absolute value for the duty  
cycle:
---  * duty<1:0> are the 2 LSbits
---  * duty<9:2> are the 8 MSbits
--- Allowed range: 0..1023
--- Note: pin_CCP9_direction should be set to output!
-procedure pwm9_set_dutycycle_highres(word in duty) is
-
-   if (duty > 1023) then                            -- upper limit
-      duty = 1023
-   end if
-   _ccpr9l_shadow = byte(duty >> 2)
-   _ccp9con_shadow_dc9b = byte(duty) & 0b11
-
-   pwm9_on()                                        -- activate PWM
-
-end procedure
-
-
--- Set dutycycle with 8-bits resolution allowing 255 PWM steps.
--- The 'duty' argument is the 8-bits absolute value for the duty cycle:
---  * duty<1:0> are the 2 LSbits
---  * duty<7:2> are the 6 MSbits
--- Allowed range: 0..255
--- Beware that steps 256..1023 are not available. In other words
--- the available PWM range is 25% of the highres procedure.
--- This procedure is particularly suitable with higher frequencies
--- whereby the PWM resolution is limited to 256 steps or less!
-procedure pwm9_set_dutycycle_lowres(byte in duty) is
-
-   _ccpr9l_shadow = duty >> 2
-   _ccp9con_shadow_dc9b = duty & 0b11
-
-   pwm9_on()                                        -- activate PWM
-
-end procedure
-
-
--- Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
--- This procedure is equivalent to pwm9_set_dutycycle_highres(), but
--- the low order 2 bits of the 10-bits duty cycle are set to 0.
--- This means that only every 4th of the available 1023 steps can be  
selected
--- and consequently max 255 PWM steps are available.
--- This procedure is for user convenience, allowing to specify an 8 bits
--- value for the duty cycle is for many applications satisfactory.
--- Calling this procedure will also activate PWM.
--- Note: pin_CCP9_direction should be set to output!
-procedure pwm9_set_dutycycle(byte in duty) is
-
-   pwm9_set_dutycycle_highres(word(duty) << 2)
-
-end procedure
-
-
--- Set a percentage duty cycle, allowing max 100 PWM steps.
--- Allowed range: 0..100
--- The duty cycle will be set to the specified percentage of the maximum
--- for the current PWM frequency.
--- Note: The number of available PWM steps can be lower than 100 with
--- (very) high PWM frequencies.
--- Note: pin_CCP9_direction should be set to output!
-procedure pwm9_set_percent_dutycycle(byte in percent) is
-
-   var word duty
-   if (percent == 0) then
-     duty = 0
-   elsif (percent >= 100) then
-     duty = _pr2_shadow_plus1 - 1
-   else
-     duty = word(percent) * (_pr2_shadow_plus1 / 4) / 25      -- (factor  
PR2/100)
-   end if
-   pwm9_set_dutycycle_highres(duty << 2)
-
-end procedure
-

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