Author: sebastien.lelong
Date: Wed Oct  8 11:42:20 2008
New Revision: 371

Modified:
    trunk/unvalidated/include/peripheral/pwm/pwm_ccp1.jal
    trunk/unvalidated/include/peripheral/pwm/pwm_ccp2.jal
    trunk/unvalidated/include/peripheral/pwm/pwm_ccp3.jal
    trunk/unvalidated/include/peripheral/pwm/pwm_ccp4.jal
    trunk/unvalidated/include/peripheral/pwm/pwm_ccp5.jal
    trunk/unvalidated/include/peripheral/pwm/pwm_common.jal

Log:
3-space indented

Modified: trunk/unvalidated/include/peripheral/pwm/pwm_ccp1.jal
==============================================================================
--- trunk/unvalidated/include/peripheral/pwm/pwm_ccp1.jal       (original)
+++ trunk/unvalidated/include/peripheral/pwm/pwm_ccp1.jal       Wed Oct  8  
11:42:20 2008
@@ -21,9 +21,9 @@
  -- This means if duty1 = 0, there's no pwm, if duty1 = 255, you're closed  
to
  -- (but not at) the maximum pwm
  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
+   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


@@ -37,30 +37,30 @@
  -- If not active yet, calling this procedure will enable PWM
  procedure pwm1_set_dutycycle_highres(word in duty) is

-       -- split word into 8 MSb and 2LSb
-       var word dutyl = duty & 0b_0000_0011
-       var word dutyh = duty >> 2
-
-       ccpr1l_shadow = byte(dutyh)
-       ccp1con_shadow = (byte(dutyl) & 0b_0000_0011) << 4
-       
-       CCPR1L  = ccpr1l_shadow
-       -- reload while (re)activating pwm
-       ccp1con_shadow = ccp1con_shadow | 0b_0000_1100
-       CCP1CON = ccp1con_shadow
+   -- split word into 8 MSb and 2LSb
+   var word dutyl = duty & 0b_0000_0011
+   var word dutyh = duty >> 2
+
+   ccpr1l_shadow = byte(dutyh)
+   ccp1con_shadow = (byte(dutyl) & 0b_0000_0011) << 4
+
+   CCPR1L  = ccpr1l_shadow
+   -- reload while (re)activating pwm
+   ccp1con_shadow = ccp1con_shadow | 0b_0000_1100
+   CCP1CON = ccp1con_shadow
  end procedure

  procedure pwm1_on() is
-       -- pwm mode on, while keeping 2 LSbits
-       ccp1con_shadow = ccp1con_shadow | 0b_0000_1100
-       CCP1CON = ccp1con_shadow
+   -- pwm mode on, while keeping 2 LSbits
+   ccp1con_shadow = ccp1con_shadow | 0b_0000_1100
+   CCP1CON = ccp1con_shadow
  end procedure


  procedure pwm1_off() is
-       -- pwm mode off, but keep 2 LSbits values
-       ccp1con_shadow = ccp1con_shadow ^ 0b_0000_1100 -- ;; Note
-       CCP1CON = ccp1con_shadow
+   -- pwm mode off, but keep 2 LSbits values
+   ccp1con_shadow = ccp1con_shadow ^ 0b_0000_1100 -- ;; Note
+   CCP1CON = ccp1con_shadow
  end procedure

  -- include common/factored part of pwm
@@ -74,43 +74,43 @@
  -- it converts the duty percent to a value suitable for the
  -- selected pwm frequency.
  procedure pwm1_set_percent_dutycycle(byte in percent) is
-       
-       -- due to a limitation in JAL, the brackects below are VERY essential
-       var dword _duty1_1  = ((percent * 4) * _pr2_1) / 100
-       var dword _duty1_4  = ((percent * 4) * _pr2_4) / 100
-       var dword _duty1_16 = ((percent * 4) * _pr2_16) / 100
-
-       var byte dutyh
-       var byte dutyl
-       -- select suitable duty value
-       if _pr2_1 == 0 then
-               ;;pragma error    -- pwm frequency is too high
-       elsif _pr2_1 <= 256 then
-               ;;ccpr1l_shadow = byte(_duty1_1 / 4)        -- 8 high order 
bits of  
dutycycle
-               ;;ccp1con_shadow = byte((_duty1_1 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty1_1 / 4)        -- 8 high order bits of 
dutycycle
-               dutyl = byte((_duty1_1 & 0b_0000_0011) * 16)
-       elsif _pr2_4 <= 256 then
-               ;;ccpr1l_shadow = byte(_duty1_4 / 4)
-               ;;ccp1con_shadow = byte((_duty1_4 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty1_4 / 4)
-               dutyl = byte((_duty1_4 & 0b_0000_0011) * 16)
-               
-       elsif _pr2_16 <= 256 then
-               -- Stef is a sioux: x * 16 <=> x << 4 !!!
-               ;;ccpr1l_shadow = byte(_duty1_16 / 4)
-               ;;ccp1con_shadow = byte((_duty1_16 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty1_16 / 4)
-               dutyl = byte((_duty1_16 & 0b_0000_0011) * 16)
-       else
-               ;;pragma error  -- pwm frequency is too low to be realized by 
this  
routine,
-               -- use the post scaler and interrupt
-       end if
-
-       -- build a word storing duty cycle high resolution'ed
-       var word duty_tmp = dutyh << 2
-       duty_tmp = dutyh | dutyl
-       pwm1_set_dutycycle_highres(duty_tmp)
+
+   -- due to a limitation in JAL, the brackects below are VERY essential
+   var dword _duty1_1  = ((percent * 4) * _pr2_1) / 100
+   var dword _duty1_4  = ((percent * 4) * _pr2_4) / 100
+   var dword _duty1_16 = ((percent * 4) * _pr2_16) / 100
+
+   var byte dutyh
+   var byte dutyl
+   -- select suitable duty value
+   if _pr2_1 == 0 then
+      ;;pragma error    -- pwm frequency is too high
+   elsif _pr2_1 <= 256 then
+      ;;ccpr1l_shadow = byte(_duty1_1 / 4)        -- 8 high order bits of  
dutycycle
+      ;;ccp1con_shadow = byte((_duty1_1 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty1_1 / 4)        -- 8 high order bits of dutycycle
+      dutyl = byte((_duty1_1 & 0b_0000_0011) * 16)
+   elsif _pr2_4 <= 256 then
+      ;;ccpr1l_shadow = byte(_duty1_4 / 4)
+      ;;ccp1con_shadow = byte((_duty1_4 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty1_4 / 4)
+      dutyl = byte((_duty1_4 & 0b_0000_0011) * 16)
+
+   elsif _pr2_16 <= 256 then
+      -- Stef is a sioux: x * 16 <=> x << 4 !!!
+      ;;ccpr1l_shadow = byte(_duty1_16 / 4)
+      ;;ccp1con_shadow = byte((_duty1_16 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty1_16 / 4)
+      dutyl = byte((_duty1_16 & 0b_0000_0011) * 16)
+   else
+      ;;pragma error  -- pwm frequency is too low to be realized by this  
routine,
+      -- use the post scaler and interrupt
+   end if
+
+   -- build a word storing duty cycle high resolution'ed
+   var word duty_tmp = dutyh << 2
+   duty_tmp = dutyh | dutyl
+   pwm1_set_dutycycle_highres(duty_tmp)


  end procedure

Modified: trunk/unvalidated/include/peripheral/pwm/pwm_ccp2.jal
==============================================================================
--- trunk/unvalidated/include/peripheral/pwm/pwm_ccp2.jal       (original)
+++ trunk/unvalidated/include/peripheral/pwm/pwm_ccp2.jal       Wed Oct  8  
11:42:20 2008
@@ -21,9 +21,9 @@
  -- This means if duty2 = 0, there's no pwm, if duty2 = 255, you're closed  
to
  -- (but not at) the maximum pwm
  procedure pwm2_set_dutycycle(byte in duty) is
-       ccpr2l_shadow = duty
-       CCPR2L  = ccpr2l_shadow   -- reload 8 high order bits of dutycycle
-       CCP2CON = ccp2con_shadow  -- reload 2 low  order bits of dutycycle
+   ccpr2l_shadow = duty
+   CCPR2L  = ccpr2l_shadow   -- reload 8 high order bits of dutycycle
+   CCP2CON = ccp2con_shadow  -- reload 2 low  order bits of dutycycle
  end procedure


@@ -37,30 +37,30 @@
  -- If not active yet, calling this procedure will enable PWM
  procedure pwm2_set_dutycycle_highres(word in duty) is

-       -- split word into 8 MSb and 2LSb
-       var word dutyl = duty & 0b_0000_0011
-       var word dutyh = duty >> 2
-
-       ccpr2l_shadow = byte(dutyh)
-       ccp2con_shadow = (byte(dutyl) & 0b_0000_0011) << 4
-       
-       CCPR2L  = ccpr2l_shadow
-       -- reload while (re)activating pwm
-       ccp2con_shadow = ccp2con_shadow | 0b_0000_1100
-       CCP2CON = ccp2con_shadow
+   -- split word into 8 MSb and 2LSb
+   var word dutyl = duty & 0b_0000_0011
+   var word dutyh = duty >> 2
+
+   ccpr2l_shadow = byte(dutyh)
+   ccp2con_shadow = (byte(dutyl) & 0b_0000_0011) << 4
+
+   CCPR2L  = ccpr2l_shadow
+   -- reload while (re)activating pwm
+   ccp2con_shadow = ccp2con_shadow | 0b_0000_1100
+   CCP2CON = ccp2con_shadow
  end procedure

  procedure pwm2_on() is
-       -- pwm mode on, while keeping 2 LSbits
-       ccp2con_shadow = ccp2con_shadow | 0b_0000_1100
-       CCP2CON = ccp2con_shadow
+   -- pwm mode on, while keeping 2 LSbits
+   ccp2con_shadow = ccp2con_shadow | 0b_0000_1100
+   CCP2CON = ccp2con_shadow
  end procedure


  procedure pwm2_off() is
-       -- pwm mode off, but keep 2 LSbits values
-       ccp2con_shadow = ccp2con_shadow ^ 0b_0000_1100 -- ;; Note
-       CCP2CON = ccp2con_shadow
+   -- pwm mode off, but keep 2 LSbits values
+   ccp2con_shadow = ccp2con_shadow ^ 0b_0000_1100 -- ;; Note
+   CCP2CON = ccp2con_shadow
  end procedure

  -- include common/factored part of pwm
@@ -74,43 +74,43 @@
  -- it converts the duty percent to a value suitable for the
  -- selected pwm frequency.
  procedure pwm2_set_percent_dutycycle(byte in percent) is
-       
-       -- due to a limitation in JAL, the brackects below are VERY essential
-       var dword _duty2_1  = ((percent * 4) * _pr2_1) / 100
-       var dword _duty2_4  = ((percent * 4) * _pr2_4) / 100
-       var dword _duty2_16 = ((percent * 4) * _pr2_16) / 100
-
-       var byte dutyh
-       var byte dutyl
-       -- select suitable duty value
-       if _pr2_1 == 0 then
-               ;;pragma error    -- pwm frequency is too high
-       elsif _pr2_1 <= 256 then
-               ;;ccpr2l_shadow = byte(_duty2_1 / 4)        -- 8 high order 
bits of  
dutycycle
-               ;;ccp2con_shadow = byte((_duty2_1 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty2_1 / 4)        -- 8 high order bits of 
dutycycle
-               dutyl = byte((_duty2_1 & 0b_0000_0011) * 16)
-       elsif _pr2_4 <= 256 then
-               ;;ccpr2l_shadow = byte(_duty2_4 / 4)
-               ;;ccp2con_shadow = byte((_duty2_4 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty2_4 / 4)
-               dutyl = byte((_duty2_4 & 0b_0000_0011) * 16)
-               
-       elsif _pr2_16 <= 256 then
-               -- Stef is a sioux: x * 16 <=> x << 4 !!!
-               ;;ccpr2l_shadow = byte(_duty2_16 / 4)
-               ;;ccp2con_shadow = byte((_duty2_16 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty2_16 / 4)
-               dutyl = byte((_duty2_16 & 0b_0000_0011) * 16)
-       else
-               ;;pragma error  -- pwm frequency is too low to be realized by 
this  
routine,
-               -- use the post scaler and interrupt
-       end if
-
-       -- build a word storing duty cycle high resolution'ed
-       var word duty_tmp = dutyh << 2
-       duty_tmp = dutyh | dutyl
-       pwm2_set_dutycycle_highres(duty_tmp)
+
+   -- due to a limitation in JAL, the brackects below are VERY essential
+   var dword _duty2_1  = ((percent * 4) * _pr2_1) / 100
+   var dword _duty2_4  = ((percent * 4) * _pr2_4) / 100
+   var dword _duty2_16 = ((percent * 4) * _pr2_16) / 100
+
+   var byte dutyh
+   var byte dutyl
+   -- select suitable duty value
+   if _pr2_1 == 0 then
+      ;;pragma error    -- pwm frequency is too high
+   elsif _pr2_1 <= 256 then
+      ;;ccpr2l_shadow = byte(_duty2_1 / 4)        -- 8 high order bits of  
dutycycle
+      ;;ccp2con_shadow = byte((_duty2_1 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty2_1 / 4)        -- 8 high order bits of dutycycle
+      dutyl = byte((_duty2_1 & 0b_0000_0011) * 16)
+   elsif _pr2_4 <= 256 then
+      ;;ccpr2l_shadow = byte(_duty2_4 / 4)
+      ;;ccp2con_shadow = byte((_duty2_4 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty2_4 / 4)
+      dutyl = byte((_duty2_4 & 0b_0000_0011) * 16)
+
+   elsif _pr2_16 <= 256 then
+      -- Stef is a sioux: x * 16 <=> x << 4 !!!
+      ;;ccpr2l_shadow = byte(_duty2_16 / 4)
+      ;;ccp2con_shadow = byte((_duty2_16 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty2_16 / 4)
+      dutyl = byte((_duty2_16 & 0b_0000_0011) * 16)
+   else
+      ;;pragma error  -- pwm frequency is too low to be realized by this  
routine,
+      -- use the post scaler and interrupt
+   end if
+
+   -- build a word storing duty cycle high resolution'ed
+   var word duty_tmp = dutyh << 2
+   duty_tmp = dutyh | dutyl
+   pwm2_set_dutycycle_highres(duty_tmp)


  end procedure

Modified: trunk/unvalidated/include/peripheral/pwm/pwm_ccp3.jal
==============================================================================
--- trunk/unvalidated/include/peripheral/pwm/pwm_ccp3.jal       (original)
+++ trunk/unvalidated/include/peripheral/pwm/pwm_ccp3.jal       Wed Oct  8  
11:42:20 2008
@@ -21,9 +21,9 @@
  -- This means if duty3 = 0, there's no pwm, if duty3 = 255, you're closed  
to
  -- (but not at) the maximum pwm
  procedure pwm3_set_dutycycle(byte in duty) is
-       ccpr3l_shadow = duty
-       CCPR3L  = ccpr3l_shadow   -- reload 8 high order bits of dutycycle
-       CCP3CON = ccp3con_shadow  -- reload 2 low  order bits of dutycycle
+   ccpr3l_shadow = duty
+   CCPR3L  = ccpr3l_shadow   -- reload 8 high order bits of dutycycle
+   CCP3CON = ccp3con_shadow  -- reload 2 low  order bits of dutycycle
  end procedure


@@ -37,30 +37,30 @@
  -- If not active yet, calling this procedure will enable PWM
  procedure pwm3_set_dutycycle_highres(word in duty) is

-       -- split word into 8 MSb and 2LSb
-       var word dutyl = duty & 0b_0000_0011
-       var word dutyh = duty >> 2
-
-       ccpr3l_shadow = byte(dutyh)
-       ccp3con_shadow = (byte(dutyl) & 0b_0000_0011) << 4
-       
-       CCPR3L  = ccpr3l_shadow
-       -- reload while (re)activating pwm
-       ccp3con_shadow = ccp3con_shadow | 0b_0000_1100
-       CCP3CON = ccp3con_shadow
+   -- split word into 8 MSb and 2LSb
+   var word dutyl = duty & 0b_0000_0011
+   var word dutyh = duty >> 2
+
+   ccpr3l_shadow = byte(dutyh)
+   ccp3con_shadow = (byte(dutyl) & 0b_0000_0011) << 4
+
+   CCPR3L  = ccpr3l_shadow
+   -- reload while (re)activating pwm
+   ccp3con_shadow = ccp3con_shadow | 0b_0000_1100
+   CCP3CON = ccp3con_shadow
  end procedure

  procedure pwm3_on() is
-       -- pwm mode on, while keeping 2 LSbits
-       ccp3con_shadow = ccp3con_shadow | 0b_0000_1100
-       CCP3CON = ccp3con_shadow
+   -- pwm mode on, while keeping 2 LSbits
+   ccp3con_shadow = ccp3con_shadow | 0b_0000_1100
+   CCP3CON = ccp3con_shadow
  end procedure


  procedure pwm3_off() is
-       -- pwm mode off, but keep 2 LSbits values
-       ccp3con_shadow = ccp3con_shadow ^ 0b_0000_1100 -- ;; Note
-       CCP3CON = ccp3con_shadow
+   -- pwm mode off, but keep 2 LSbits values
+   ccp3con_shadow = ccp3con_shadow ^ 0b_0000_1100 -- ;; Note
+   CCP3CON = ccp3con_shadow
  end procedure

  -- include common/factored part of pwm
@@ -74,43 +74,43 @@
  -- it converts the duty percent to a value suitable for the
  -- selected pwm frequency.
  procedure pwm3_set_percent_dutycycle(byte in percent) is
-       
-       -- due to a limitation in JAL, the brackects below are VERY essential
-       var dword _duty3_1  = ((percent * 4) * _pr2_1) / 100
-       var dword _duty3_4  = ((percent * 4) * _pr2_4) / 100
-       var dword _duty3_16 = ((percent * 4) * _pr2_16) / 100
-
-       var byte dutyh
-       var byte dutyl
-       -- select suitable duty value
-       if _pr2_1 == 0 then
-               ;;pragma error    -- pwm frequency is too high
-       elsif _pr2_1 <= 256 then
-               ;;ccpr3l_shadow = byte(_duty3_1 / 4)        -- 8 high order 
bits of  
dutycycle
-               ;;ccp3con_shadow = byte((_duty3_1 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty3_1 / 4)        -- 8 high order bits of 
dutycycle
-               dutyl = byte((_duty3_1 & 0b_0000_0011) * 16)
-       elsif _pr2_4 <= 256 then
-               ;;ccpr3l_shadow = byte(_duty3_4 / 4)
-               ;;ccp3con_shadow = byte((_duty3_4 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty3_4 / 4)
-               dutyl = byte((_duty3_4 & 0b_0000_0011) * 16)
-               
-       elsif _pr2_16 <= 256 then
-               -- Stef is a sioux: x * 16 <=> x << 4 !!!
-               ;;ccpr3l_shadow = byte(_duty3_16 / 4)
-               ;;ccp3con_shadow = byte((_duty3_16 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty3_16 / 4)
-               dutyl = byte((_duty3_16 & 0b_0000_0011) * 16)
-       else
-               ;;pragma error  -- pwm frequency is too low to be realized by 
this  
routine,
-               -- use the post scaler and interrupt
-       end if
-
-       -- build a word storing duty cycle high resolution'ed
-       var word duty_tmp = dutyh << 2
-       duty_tmp = dutyh | dutyl
-       pwm3_set_dutycycle_highres(duty_tmp)
+
+   -- due to a limitation in JAL, the brackects below are VERY essential
+   var dword _duty3_1  = ((percent * 4) * _pr2_1) / 100
+   var dword _duty3_4  = ((percent * 4) * _pr2_4) / 100
+   var dword _duty3_16 = ((percent * 4) * _pr2_16) / 100
+
+   var byte dutyh
+   var byte dutyl
+   -- select suitable duty value
+   if _pr2_1 == 0 then
+      ;;pragma error    -- pwm frequency is too high
+   elsif _pr2_1 <= 256 then
+      ;;ccpr3l_shadow = byte(_duty3_1 / 4)        -- 8 high order bits of  
dutycycle
+      ;;ccp3con_shadow = byte((_duty3_1 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty3_1 / 4)        -- 8 high order bits of dutycycle
+      dutyl = byte((_duty3_1 & 0b_0000_0011) * 16)
+   elsif _pr2_4 <= 256 then
+      ;;ccpr3l_shadow = byte(_duty3_4 / 4)
+      ;;ccp3con_shadow = byte((_duty3_4 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty3_4 / 4)
+      dutyl = byte((_duty3_4 & 0b_0000_0011) * 16)
+
+   elsif _pr2_16 <= 256 then
+      -- Stef is a sioux: x * 16 <=> x << 4 !!!
+      ;;ccpr3l_shadow = byte(_duty3_16 / 4)
+      ;;ccp3con_shadow = byte((_duty3_16 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty3_16 / 4)
+      dutyl = byte((_duty3_16 & 0b_0000_0011) * 16)
+   else
+      ;;pragma error  -- pwm frequency is too low to be realized by this  
routine,
+      -- use the post scaler and interrupt
+   end if
+
+   -- build a word storing duty cycle high resolution'ed
+   var word duty_tmp = dutyh << 2
+   duty_tmp = dutyh | dutyl
+   pwm3_set_dutycycle_highres(duty_tmp)


  end procedure

Modified: trunk/unvalidated/include/peripheral/pwm/pwm_ccp4.jal
==============================================================================
--- trunk/unvalidated/include/peripheral/pwm/pwm_ccp4.jal       (original)
+++ trunk/unvalidated/include/peripheral/pwm/pwm_ccp4.jal       Wed Oct  8  
11:42:20 2008
@@ -21,9 +21,9 @@
  -- This means if duty4 = 0, there's no pwm, if duty4 = 255, you're closed  
to
  -- (but not at) the maximum pwm
  procedure pwm4_set_dutycycle(byte in duty) is
-       ccpr4l_shadow = duty
-       CCPR4L  = ccpr4l_shadow   -- reload 8 high order bits of dutycycle
-       CCP4CON = ccp4con_shadow  -- reload 2 low  order bits of dutycycle
+   ccpr4l_shadow = duty
+   CCPR4L  = ccpr4l_shadow   -- reload 8 high order bits of dutycycle
+   CCP4CON = ccp4con_shadow  -- reload 2 low  order bits of dutycycle
  end procedure


@@ -37,30 +37,30 @@
  -- If not active yet, calling this procedure will enable PWM
  procedure pwm4_set_dutycycle_highres(word in duty) is

-       -- split word into 8 MSb and 2LSb
-       var word dutyl = duty & 0b_0000_0011
-       var word dutyh = duty >> 2
-
-       ccpr4l_shadow = byte(dutyh)
-       ccp4con_shadow = (byte(dutyl) & 0b_0000_0011) << 4
-       
-       CCPR4L  = ccpr4l_shadow
-       -- reload while (re)activating pwm
-       ccp4con_shadow = ccp4con_shadow | 0b_0000_1100
-       CCP4CON = ccp4con_shadow
+   -- split word into 8 MSb and 2LSb
+   var word dutyl = duty & 0b_0000_0011
+   var word dutyh = duty >> 2
+
+   ccpr4l_shadow = byte(dutyh)
+   ccp4con_shadow = (byte(dutyl) & 0b_0000_0011) << 4
+
+   CCPR4L  = ccpr4l_shadow
+   -- reload while (re)activating pwm
+   ccp4con_shadow = ccp4con_shadow | 0b_0000_1100
+   CCP4CON = ccp4con_shadow
  end procedure

  procedure pwm4_on() is
-       -- pwm mode on, while keeping 2 LSbits
-       ccp4con_shadow = ccp4con_shadow | 0b_0000_1100
-       CCP4CON = ccp4con_shadow
+   -- pwm mode on, while keeping 2 LSbits
+   ccp4con_shadow = ccp4con_shadow | 0b_0000_1100
+   CCP4CON = ccp4con_shadow
  end procedure


  procedure pwm4_off() is
-       -- pwm mode off, but keep 2 LSbits values
-       ccp4con_shadow = ccp4con_shadow ^ 0b_0000_1100 -- ;; Note
-       CCP4CON = ccp4con_shadow
+   -- pwm mode off, but keep 2 LSbits values
+   ccp4con_shadow = ccp4con_shadow ^ 0b_0000_1100 -- ;; Note
+   CCP4CON = ccp4con_shadow
  end procedure

  -- include common/factored part of pwm
@@ -74,43 +74,43 @@
  -- it converts the duty percent to a value suitable for the
  -- selected pwm frequency.
  procedure pwm4_set_percent_dutycycle(byte in percent) is
-       
-       -- due to a limitation in JAL, the brackects below are VERY essential
-       var dword _duty4_1  = ((percent * 4) * _pr2_1) / 100
-       var dword _duty4_4  = ((percent * 4) * _pr2_4) / 100
-       var dword _duty4_16 = ((percent * 4) * _pr2_16) / 100
-
-       var byte dutyh
-       var byte dutyl
-       -- select suitable duty value
-       if _pr2_1 == 0 then
-               ;;pragma error    -- pwm frequency is too high
-       elsif _pr2_1 <= 256 then
-               ;;ccpr4l_shadow = byte(_duty4_1 / 4)        -- 8 high order 
bits of  
dutycycle
-               ;;ccp4con_shadow = byte((_duty4_1 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty4_1 / 4)        -- 8 high order bits of 
dutycycle
-               dutyl = byte((_duty4_1 & 0b_0000_0011) * 16)
-       elsif _pr2_4 <= 256 then
-               ;;ccpr4l_shadow = byte(_duty4_4 / 4)
-               ;;ccp4con_shadow = byte((_duty4_4 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty4_4 / 4)
-               dutyl = byte((_duty4_4 & 0b_0000_0011) * 16)
-               
-       elsif _pr2_16 <= 256 then
-               -- Stef is a sioux: x * 16 <=> x << 4 !!!
-               ;;ccpr4l_shadow = byte(_duty4_16 / 4)
-               ;;ccp4con_shadow = byte((_duty4_16 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty4_16 / 4)
-               dutyl = byte((_duty4_16 & 0b_0000_0011) * 16)
-       else
-               ;;pragma error  -- pwm frequency is too low to be realized by 
this  
routine,
-               -- use the post scaler and interrupt
-       end if
-
-       -- build a word storing duty cycle high resolution'ed
-       var word duty_tmp = dutyh << 2
-       duty_tmp = dutyh | dutyl
-       pwm4_set_dutycycle_highres(duty_tmp)
+
+   -- due to a limitation in JAL, the brackects below are VERY essential
+   var dword _duty4_1  = ((percent * 4) * _pr2_1) / 100
+   var dword _duty4_4  = ((percent * 4) * _pr2_4) / 100
+   var dword _duty4_16 = ((percent * 4) * _pr2_16) / 100
+
+   var byte dutyh
+   var byte dutyl
+   -- select suitable duty value
+   if _pr2_1 == 0 then
+      ;;pragma error    -- pwm frequency is too high
+   elsif _pr2_1 <= 256 then
+      ;;ccpr4l_shadow = byte(_duty4_1 / 4)        -- 8 high order bits of  
dutycycle
+      ;;ccp4con_shadow = byte((_duty4_1 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty4_1 / 4)        -- 8 high order bits of dutycycle
+      dutyl = byte((_duty4_1 & 0b_0000_0011) * 16)
+   elsif _pr2_4 <= 256 then
+      ;;ccpr4l_shadow = byte(_duty4_4 / 4)
+      ;;ccp4con_shadow = byte((_duty4_4 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty4_4 / 4)
+      dutyl = byte((_duty4_4 & 0b_0000_0011) * 16)
+
+   elsif _pr2_16 <= 256 then
+      -- Stef is a sioux: x * 16 <=> x << 4 !!!
+      ;;ccpr4l_shadow = byte(_duty4_16 / 4)
+      ;;ccp4con_shadow = byte((_duty4_16 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty4_16 / 4)
+      dutyl = byte((_duty4_16 & 0b_0000_0011) * 16)
+   else
+      ;;pragma error  -- pwm frequency is too low to be realized by this  
routine,
+      -- use the post scaler and interrupt
+   end if
+
+   -- build a word storing duty cycle high resolution'ed
+   var word duty_tmp = dutyh << 2
+   duty_tmp = dutyh | dutyl
+   pwm4_set_dutycycle_highres(duty_tmp)


  end procedure

Modified: trunk/unvalidated/include/peripheral/pwm/pwm_ccp5.jal
==============================================================================
--- trunk/unvalidated/include/peripheral/pwm/pwm_ccp5.jal       (original)
+++ trunk/unvalidated/include/peripheral/pwm/pwm_ccp5.jal       Wed Oct  8  
11:42:20 2008
@@ -21,9 +21,9 @@
  -- This means if duty5 = 0, there's no pwm, if duty5 = 255, you're closed  
to
  -- (but not at) the maximum pwm
  procedure pwm5_set_dutycycle(byte in duty) is
-       ccpr5l_shadow = duty
-       CCPR5L  = ccpr5l_shadow   -- reload 8 high order bits of dutycycle
-       CCP5CON = ccp5con_shadow  -- reload 2 low  order bits of dutycycle
+   ccpr5l_shadow = duty
+   CCPR5L  = ccpr5l_shadow   -- reload 8 high order bits of dutycycle
+   CCP5CON = ccp5con_shadow  -- reload 2 low  order bits of dutycycle
  end procedure


@@ -37,30 +37,30 @@
  -- If not active yet, calling this procedure will enable PWM
  procedure pwm5_set_dutycycle_highres(word in duty) is

-       -- split word into 8 MSb and 2LSb
-       var word dutyl = duty & 0b_0000_0011
-       var word dutyh = duty >> 2
-
-       ccpr5l_shadow = byte(dutyh)
-       ccp5con_shadow = (byte(dutyl) & 0b_0000_0011) << 4
-       
-       CCPR5L  = ccpr5l_shadow
-       -- reload while (re)activating pwm
-       ccp5con_shadow = ccp5con_shadow | 0b_0000_1100
-       CCP5CON = ccp5con_shadow
+   -- split word into 8 MSb and 2LSb
+   var word dutyl = duty & 0b_0000_0011
+   var word dutyh = duty >> 2
+
+   ccpr5l_shadow = byte(dutyh)
+   ccp5con_shadow = (byte(dutyl) & 0b_0000_0011) << 4
+
+   CCPR5L  = ccpr5l_shadow
+   -- reload while (re)activating pwm
+   ccp5con_shadow = ccp5con_shadow | 0b_0000_1100
+   CCP5CON = ccp5con_shadow
  end procedure

  procedure pwm5_on() is
-       -- pwm mode on, while keeping 2 LSbits
-       ccp5con_shadow = ccp5con_shadow | 0b_0000_1100
-       CCP5CON = ccp5con_shadow
+   -- pwm mode on, while keeping 2 LSbits
+   ccp5con_shadow = ccp5con_shadow | 0b_0000_1100
+   CCP5CON = ccp5con_shadow
  end procedure


  procedure pwm5_off() is
-       -- pwm mode off, but keep 2 LSbits values
-       ccp5con_shadow = ccp5con_shadow ^ 0b_0000_1100 -- ;; Note
-       CCP5CON = ccp5con_shadow
+   -- pwm mode off, but keep 2 LSbits values
+   ccp5con_shadow = ccp5con_shadow ^ 0b_0000_1100 -- ;; Note
+   CCP5CON = ccp5con_shadow
  end procedure

  -- include common/factored part of pwm
@@ -74,43 +74,43 @@
  -- it converts the duty percent to a value suitable for the
  -- selected pwm frequency.
  procedure pwm5_set_percent_dutycycle(byte in percent) is
-       
-       -- due to a limitation in JAL, the brackects below are VERY essential
-       var dword _duty5_1  = ((percent * 4) * _pr2_1) / 100
-       var dword _duty5_4  = ((percent * 4) * _pr2_4) / 100
-       var dword _duty5_16 = ((percent * 4) * _pr2_16) / 100
-
-       var byte dutyh
-       var byte dutyl
-       -- select suitable duty value
-       if _pr2_1 == 0 then
-               ;;pragma error    -- pwm frequency is too high
-       elsif _pr2_1 <= 256 then
-               ;;ccpr5l_shadow = byte(_duty5_1 / 4)        -- 8 high order 
bits of  
dutycycle
-               ;;ccp5con_shadow = byte((_duty5_1 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty5_1 / 4)        -- 8 high order bits of 
dutycycle
-               dutyl = byte((_duty5_1 & 0b_0000_0011) * 16)
-       elsif _pr2_4 <= 256 then
-               ;;ccpr5l_shadow = byte(_duty5_4 / 4)
-               ;;ccp5con_shadow = byte((_duty5_4 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty5_4 / 4)
-               dutyl = byte((_duty5_4 & 0b_0000_0011) * 16)
-               
-       elsif _pr2_16 <= 256 then
-               -- Stef is a sioux: x * 16 <=> x << 4 !!!
-               ;;ccpr5l_shadow = byte(_duty5_16 / 4)
-               ;;ccp5con_shadow = byte((_duty5_16 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty5_16 / 4)
-               dutyl = byte((_duty5_16 & 0b_0000_0011) * 16)
-       else
-               ;;pragma error  -- pwm frequency is too low to be realized by 
this  
routine,
-               -- use the post scaler and interrupt
-       end if
-
-       -- build a word storing duty cycle high resolution'ed
-       var word duty_tmp = dutyh << 2
-       duty_tmp = dutyh | dutyl
-       pwm5_set_dutycycle_highres(duty_tmp)
+
+   -- due to a limitation in JAL, the brackects below are VERY essential
+   var dword _duty5_1  = ((percent * 4) * _pr2_1) / 100
+   var dword _duty5_4  = ((percent * 4) * _pr2_4) / 100
+   var dword _duty5_16 = ((percent * 4) * _pr2_16) / 100
+
+   var byte dutyh
+   var byte dutyl
+   -- select suitable duty value
+   if _pr2_1 == 0 then
+      ;;pragma error    -- pwm frequency is too high
+   elsif _pr2_1 <= 256 then
+      ;;ccpr5l_shadow = byte(_duty5_1 / 4)        -- 8 high order bits of  
dutycycle
+      ;;ccp5con_shadow = byte((_duty5_1 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty5_1 / 4)        -- 8 high order bits of dutycycle
+      dutyl = byte((_duty5_1 & 0b_0000_0011) * 16)
+   elsif _pr2_4 <= 256 then
+      ;;ccpr5l_shadow = byte(_duty5_4 / 4)
+      ;;ccp5con_shadow = byte((_duty5_4 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty5_4 / 4)
+      dutyl = byte((_duty5_4 & 0b_0000_0011) * 16)
+
+   elsif _pr2_16 <= 256 then
+      -- Stef is a sioux: x * 16 <=> x << 4 !!!
+      ;;ccpr5l_shadow = byte(_duty5_16 / 4)
+      ;;ccp5con_shadow = byte((_duty5_16 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty5_16 / 4)
+      dutyl = byte((_duty5_16 & 0b_0000_0011) * 16)
+   else
+      ;;pragma error  -- pwm frequency is too low to be realized by this  
routine,
+      -- use the post scaler and interrupt
+   end if
+
+   -- build a word storing duty cycle high resolution'ed
+   var word duty_tmp = dutyh << 2
+   duty_tmp = dutyh | dutyl
+   pwm5_set_dutycycle_highres(duty_tmp)


  end procedure

Modified: trunk/unvalidated/include/peripheral/pwm/pwm_common.jal
==============================================================================
--- trunk/unvalidated/include/peripheral/pwm/pwm_common.jal     (original)
+++ trunk/unvalidated/include/peripheral/pwm/pwm_common.jal     Wed Oct  8  
11:42:20 2008
@@ -13,7 +13,7 @@
  -- Notes: this is a heavy refactoring of the original pwm_hardware.jal
  -- Stef's lib
  --
-
+


  -- initializes the PWM for high resolution (10 bits) and starts the PWM
@@ -34,20 +34,20 @@
  -- ||    16            ||     244Hz  ||     488Hz  ||    610Hz   ||     
1.22kHz ||
  --
  procedure pwm_max_resolution(byte in prescaler) is
-       -- set timervalue to maximum resolution
-       PR2 = 0xFF
-       
-       -- set TMR2 prescaler and turn TMR2 on
-       if prescaler == 1 then
-               T2CON = 0b_0000_0100
-       elsif prescaler == 4  then
-               T2CON = 0b_0000_0101
-       elsif prescaler == 16 then
-               T2CON = 0b_0000_0111
-       else
-               ;THIS PRAGMA IS NOT CORRECTLY HANDLED BY JAL $.59 !!
-               ;pragma error  ;pwm frequency is not allowed for high resolution
-       end if
+   -- set timervalue to maximum resolution
+   PR2 = 0xFF
+
+   -- set TMR2 prescaler and turn TMR2 on
+   if prescaler == 1 then
+      T2CON = 0b_0000_0100
+   elsif prescaler == 4  then
+      T2CON = 0b_0000_0101
+   elsif prescaler == 16 then
+      T2CON = 0b_0000_0111
+   else
+      ;THIS PRAGMA IS NOT CORRECTLY HANDLED BY JAL $.59 !!
+      ;pragma error  ;pwm frequency is not allowed for high resolution
+   end if
  end procedure


@@ -63,38 +63,38 @@

  -- Initializes the PWM for accurate frequency and starts the PWM
  procedure pwm_set_frequency(dword in freq) is
-       -- compute all values
-       _pr2_1 = target_clock / ( 1 *  4 * freq )
-       _pr2_4   = target_clock / ( 4 *  4 * freq )
-       _pr2_16  = target_clock / ( 16 * 4 * freq )
-       -- calculate prescaler and divider
-       var byte pre_scaler
-       if _pr2_1 == 0 then
-               -- since now it's a byte, cannot pragma error'ing...
-               -- what should we do ?
-               ;;pragma error    -- pwm frequency is too high
-               -- turn pwm off
-               pre_scaler = 0b_0000_0000
-       elsif _pr2_1 <= 256 then
-               PR2 = byte(_pr2_1) - 1                     -- load timer value 
(base  
period)
-               pre_scaler = 0b_0000_0100
-       elsif _pr2_4 <= 256 then
-               PR2 = byte(_pr2_4) - 1
-               pre_scaler = 0b_0000_0101
-       elsif _pr2_16 <= 256 then
-               PR2 = byte(_pr2_16) - 1
-               pre_scaler = 0b_0000_0110
-       else
-               -- again, cannot pragma error'ing...
-               ;;pragma error  -- pwm frequency is too low to be realized by 
this  
routine,
-               ;;-- use the post scaler and interrupt
-               pre_scaler = 0b_0000_0000
-       end if
-
-       -- load tmr2 prescaler, and turn it on
-       -- (post-scaler is not used in PWM !!)
-       var byte t2con_tmp = T2CON & 0b_1111_1000
-       T2CON   = t2con_tmp | pre_scaler
+   -- compute all values
+   _pr2_1 = target_clock / ( 1 *  4 * freq )
+   _pr2_4   = target_clock / ( 4 *  4 * freq )
+   _pr2_16  = target_clock / ( 16 * 4 * freq )
+   -- calculate prescaler and divider
+   var byte pre_scaler
+   if _pr2_1 == 0 then
+      -- since now it's a byte, cannot pragma error'ing...
+      -- what should we do ?
+      ;;pragma error    -- pwm frequency is too high
+      -- turn pwm off
+      pre_scaler = 0b_0000_0000
+   elsif _pr2_1 <= 256 then
+      PR2 = byte(_pr2_1) - 1                     -- load timer value (base  
period)
+      pre_scaler = 0b_0000_0100
+   elsif _pr2_4 <= 256 then
+      PR2 = byte(_pr2_4) - 1
+      pre_scaler = 0b_0000_0101
+   elsif _pr2_16 <= 256 then
+      PR2 = byte(_pr2_16) - 1
+      pre_scaler = 0b_0000_0110
+   else
+      -- again, cannot pragma error'ing...
+      ;;pragma error  -- pwm frequency is too low to be realized by this  
routine,
+      ;;-- use the post scaler and interrupt
+      pre_scaler = 0b_0000_0000
+   end if
+
+   -- load tmr2 prescaler, and turn it on
+   -- (post-scaler is not used in PWM !!)
+   var byte t2con_tmp = T2CON & 0b_1111_1000
+   T2CON   = t2con_tmp | pre_scaler

  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