Author: sebastien.lelong
Date: Sat Sep  6 02:49:29 2008
New Revision: 280

Modified:
    trunk/unvalidated/include/jal/delay_any_mc.jal
    trunk/unvalidated/include/peripheral/adc/adc_hardware.jal
    trunk/unvalidated/include/peripheral/data_eeprom/pic_data_eeprom.jal
    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
    trunk/unvalidated/include/peripheral/usart/serial_hardware.jal

Log:
clean, improve doc, remove long dashes lines in comments

Modified: trunk/unvalidated/include/jal/delay_any_mc.jal
==============================================================================
--- trunk/unvalidated/include/jal/delay_any_mc.jal      (original)
+++ trunk/unvalidated/include/jal/delay_any_mc.jal      Sat Sep  6 02:49:29 2008
@@ -21,101 +21,71 @@
  --   delay_1ms   ( N )
  --   delay_100ms ( N )
  --
---  
-----------------------------------------------------------------------------


---  
-----------------------------------------------------------------------------
  -- fixed delay of 1 usec (no arguments)
---  
-----------------------------------------------------------------------------
  procedure delay_1us() is      ; (2) call
        asm nop                                 ; (1)
  end procedure                         ; (2)
---  
-----------------------------------------------------------------------------


---  
-----------------------------------------------------------------------------
  -- fixed delay of 2 usec (no arguments)
---  
-----------------------------------------------------------------------------
  procedure delay_2us() is
        _usec_delay(1)
        asm  nop
  end procedure
---  
-----------------------------------------------------------------------------


---  
-----------------------------------------------------------------------------
  -- fixed delay of 3 usec (no arguments)
---  
-----------------------------------------------------------------------------
  procedure delay_3us() is
        _usec_delay(2)
        asm  nop
  end procedure
---  
-----------------------------------------------------------------------------


---  
-----------------------------------------------------------------------------
  -- fixed delay of 4 usec (no arguments)
---  
-----------------------------------------------------------------------------
  procedure delay_4us() is
        _usec_delay(3)
        asm  nop
  end procedure
---  
-----------------------------------------------------------------------------


---  
-----------------------------------------------------------------------------
  -- fixed delay of 5 usec (no arguments)
---  
-----------------------------------------------------------------------------
  procedure delay_5us() is
        _usec_delay(4)
        asm  nop
  end procedure
---  
-----------------------------------------------------------------------------


---  
-----------------------------------------------------------------------------
  -- fixed delay of 6 usec (no arguments)
---  
-----------------------------------------------------------------------------
  procedure delay_6us() is
        _usec_delay(5)
        asm  nop
  end procedure
---  
-----------------------------------------------------------------------------


---  
-----------------------------------------------------------------------------
  -- fixed delay of 7 usec (no arguments)
---  
-----------------------------------------------------------------------------
  procedure delay_7us() is
        _usec_delay(6)
        asm  nop
  end procedure
---  
-----------------------------------------------------------------------------


---  
-----------------------------------------------------------------------------
  -- fixed delay of 8 usec (no arguments)
---  
-----------------------------------------------------------------------------
  procedure delay_8us() is
        _usec_delay(7)
        asm  nop
  end procedure
---  
-----------------------------------------------------------------------------


---  
-----------------------------------------------------------------------------
  -- fixed delay of 9 usec (no arguments)
---  
-----------------------------------------------------------------------------
  procedure delay_9us() is
        _usec_delay(8)
        asm  nop
  end procedure
---  
-----------------------------------------------------------------------------


---  
-----------------------------------------------------------------------------
  -- Delays for N * 10 usec
---  
-----------------------------------------------------------------------------
  procedure delay_10us(byte in N) is
        if N==1 then
                _usec_delay(7)
@@ -136,27 +106,20 @@
        asm  nop
        asm  nop
  end procedure
---  
-----------------------------------------------------------------------------


---  
-----------------------------------------------------------------------------
  -- Delays for N * 1 msec
---  
-----------------------------------------------------------------------------
  procedure delay_1ms(byte in N) is
    for N loop
        _usec_delay(995)
    end loop
  end procedure
---  
-----------------------------------------------------------------------------


---  
-----------------------------------------------------------------------------
  -- Delays for N * 100 msec
---  
-----------------------------------------------------------------------------
  procedure delay_100ms(word in N) is
        for N loop
                _usec_delay(99995)
        end loop
  end procedure
---  
-----------------------------------------------------------------------------


Modified: trunk/unvalidated/include/peripheral/adc/adc_hardware.jal
==============================================================================
--- trunk/unvalidated/include/peripheral/adc/adc_hardware.jal   (original)
+++ trunk/unvalidated/include/peripheral/adc/adc_hardware.jal   Sat Sep  6  
02:49:29 2008
@@ -7,43 +7,40 @@
  -- Released under the BSD license  
(http://www.opensource.org/licenses/bsd-license.php)
  --
  -- Sources: I (Stef) mixed the following libraries with my own ideas
---    f877_modules.jal from Javier Martinez
---    janalog.jal from Vasile Surducan
+--  * f877_modules.jal from Javier Martinez
+--  * janalog.jal from Vasile Surducan
  --
  -- Description: library to use the PIC's AD converter
  -- See 16F87x datasheet (DS30292C, p112)
--- Nnumber of channels, behind "--" yields only for 16F874 and 16F877
--- Nno external Vref: Nchan = 1,3,5 -- 6,8
--- Oonly external +Vref: Nchan = 2,4 -- 5,7
--- Bboth external +Vref and - Vref: Nchan = 1,2,3 -- 4,6
+-- Number of channels, behind "--" yields only for 16F874 and 16F877
+-- No external Vref: Nchan = 1,3,5 -- 6,8
+-- Only external +Vref: Nchan = 2,4 -- 5,7
+-- Both external +Vref and - Vref: Nchan = 1,2,3 -- 4,6
  -- --
  -- Analog channels can still be used as digital outputs, by setting
  --     pin = output
  -- --
  -- relevant IO pins
---             RA0 = AN0
---             RA1 = AN1
---             RA2 = AN2  or  -Vref
---             RA3 = AN3  or  +Vref
---             RA4 = no analog IO
---             RA5 = AN4
---             next pins only for 16F874 and 16F877
---             RE0 = AN5
---             RE1 = AN6
---             RE2 = AN7
+--     * RA0 = AN0
+--     * RA1 = AN1
+--     * RA2 = AN2  or  -Vref
+--     * RA3 = AN3  or  +Vref
+--     * RA4 = no analog IO
+--     * RA5 = AN4
+--     * next pins only for 16F874 and 16F877
+--     * RE0 = AN5
+--     * RE1 = AN6
+--     * RE2 = AN7
  --


---  
-----------------------------------------------------------------------------
  -- local variables
---  
-----------------------------------------------------------------------------
+
  var volatile byte _adcon0_shadow = 0
  var volatile byte _adc_conversion_time


---  
-----------------------------------------------------------------------------
  -- Does an AD conversion with low resolution (8 bit) on the selected  
channel
---  
-----------------------------------------------------------------------------
  procedure _adc_read_low_res(byte in adc_chan, byte out adc_byte) is

        if target_chip == PIC_12F675 then
@@ -62,11 +59,9 @@
  end procedure


---  
-----------------------------------------------------------------------------
  -- Does an AD conversion on the selected channel
  -- returns the result as a 10-bits word
  -- It doesn't matter if ADC is set to low or high resolution
---  
-----------------------------------------------------------------------------
  function adc_read(byte in adc_chan) return word is
        var word ad_value
        var byte ax[2] at ad_value
@@ -86,11 +81,9 @@
  end function


---  
-----------------------------------------------------------------------------
  -- Does an AD conversion on the selected channel
  -- returns the 10-bit result as 2 byte parameters
  -- It doesn't matter if ADC is set to low or high resolution
---  
-----------------------------------------------------------------------------
  procedure adc_read_bytes(byte in adc_chan, byte out adc_hbyte, byte out  
adc_lbyte) is
        var word ad_value
        var byte ax[2] at ad_value
@@ -100,10 +93,8 @@
  end procedure


---  
-----------------------------------------------------------------------------
  -- Returns Low Resolution ADC-value as the RESULT
  -- It doesn't matter if ADC is set to low or high resolution
---  
-----------------------------------------------------------------------------
  function adc_read_low_res(byte in adc_chan) return byte is
        var byte adc_value
        var byte adc_hbyte
@@ -122,11 +113,9 @@
  end function


---  
-----------------------------------------------------------------------------
--- internal routine, that
+-- Internal routine, that
  -- calculates aquisition time
  -- and determines if right or left justification is optimal
---  
-----------------------------------------------------------------------------
  procedure _ad_init_general() is
        -- if high resolution, right justified, read H + L
        -- if low  resolution, left  justified, only read H
@@ -181,13 +170,11 @@
  end procedure


---  
-----------------------------------------------------------------------------
--- initializes the PIC AD-converter, when no external Vref is present
--- settings are done according to the special ADC constants
--- sets all the analog pins to input
--- calculates aquisition time
--- and determines if right or left justification is optimal
---  
-----------------------------------------------------------------------------
+-- Initializes the PIC AD-converter, when no external Vref is present
+-- Settings are done according to the special ADC constants
+-- Sets all the analog pins to input
+-- Calculates aquisition time and determines if right or
+-- left justification is optimal
  procedure _adc_init_no_vref() is
        if target_chip != PIC_12F675 then
                -- start with left justified
@@ -236,13 +223,11 @@
  end procedure


---  
-----------------------------------------------------------------------------
--- initializes the PIC AD-converter, when only +Vref is present
--- settings are done according to the special ADC constants
--- sets all the analog pins to input
--- calculates aquisition time
--- and determines if right or left justification is optimal
---  
-----------------------------------------------------------------------------
+-- Initializes the PIC AD-converter, when only +Vref is present
+-- Settings are done according to the special ADC constants
+-- Sets all the analog pins to input
+-- Calculates aquisition time and determines if right or
+-- left justification is optimal
  procedure _adc_init_1_vref() is
        if target_chip != PIC_12F675 then
                -- start with left justified
@@ -287,13 +272,11 @@
  end procedure


---  
-----------------------------------------------------------------------------
--- initializes the PIC AD-converter, when both +Vref and -Vref are present
--- settings are done according to the special ADC constants
--- sets all the analog pins to input
--- calculates aquisition time
--- and determines if right or left justification is optimal
---  
-----------------------------------------------------------------------------
+-- Initializes the PIC AD-converter, when both +Vref and -Vref are present
+-- Settings are done according to the special ADC constants
+-- Sets all the analog pins to input
+-- Calculates aquisition time and determines if right or
+-- left justification is optimal
  procedure _adc_init_2_vref() is
        if target_chip != PIC_12F675 then
                -- start with left justified
@@ -345,14 +328,12 @@
  end procedure


---  
-----------------------------------------------------------------------------
--- initializes the PIC AD-converter,
+-- Initializes the PIC AD-converter,
  -- by calling the correct routine according to the number of external  
references
--- settings are done according to the special ADC constants
--- sets all the analog pins to input
--- calculates aquisition time
--- and determines if right or left justification is optimal
---  
-----------------------------------------------------------------------------
+-- Settings are done according to the special ADC constants
+-- Sets all the analog pins to input
+-- Calculates aquisition time and determines if right or
+-- left justification is optimal
  procedure adc_init() is
        if target_chip == PIC_12F675 then
                if    adc_hardware_nvref == 0 then
@@ -377,9 +358,7 @@
  end procedure


---  
-----------------------------------------------------------------------------
--- turns all ADC channels back on
---  
-----------------------------------------------------------------------------
+-- Turns all ADC channels back on
  procedure adc_on() is
        -- jallib: this is *not* the original meaning
        -- It just turns adc on, while it previously

Modified:  
trunk/unvalidated/include/peripheral/data_eeprom/pic_data_eeprom.jal
==============================================================================
--- trunk/unvalidated/include/peripheral/data_eeprom/pic_data_eeprom.jal        
 
(original)
+++ trunk/unvalidated/include/peripheral/data_eeprom/pic_data_eeprom.jal        
 
Sat Sep  6 02:49:29 2008
@@ -11,9 +11,8 @@
  --


--- --------------------------------------------------------------------
--- reading of data-EEprom
--- --------------------------------------------------------------------
+-- Reads a byte from data eeprom at given address
+-- Result is stored in the passed in argument
  procedure data_eeprom_read( byte in address, byte out data ) is
        EEADR = address
        if defined(EECON1_EEPGD) == true then
@@ -22,13 +21,17 @@
        EECON1_RD = true
        data = EEDATA
  end procedure
--- --------------------------------------------------------------------
+
+-- Reads a word from data eeprom at given address
+-- Result is stored in the passed in argument
  procedure data_eeprom_read_word( byte in address, word out data ) is
        var byte temp[2] at data
        data_eeprom_read(address,temp[0])
        data_eeprom_read(address+1,temp[1])
  end procedure
--- --------------------------------------------------------------------
+
+-- Reads a dword from data eeprom at given address
+-- Result is stored in the passed in argument
  procedure data_eeprom_read_dword( byte in address, dword out data ) is
        var byte temp[4] at data
        data_eeprom_read(address,temp[0])
@@ -36,35 +39,36 @@
        data_eeprom_read(address+2,temp[2])
        data_eeprom_read(address+3,temp[3])
  end procedure
--- --------------------------------------------------------------------


--- --------------------------------------------------------------------
--- data_eeprom_read as a function
--- --------------------------------------------------------------------
+
+-- Reads a byte from data eeprom at given address
+-- and return the result
  function data_eeprom(byte in address) return byte is
        var byte data
        data_eeprom_read(address,data)
        return data
  end function
--- --------------------------------------------------------------------
+
+-- Reads a word from data eeprom at given address
+-- and return the result
  function data_eeprom_word(byte in address) return word is
        var word data
        data_eeprom_read_word(address,data)
        return data
  end function
--- --------------------------------------------------------------------
+
+-- Reads a dword from data eeprom at given address
+-- and return the result
  function data_eeprom_dword(byte in address) return dword is
        var dword data
        data_eeprom_read_dword(address,data)
        return data
  end function
--- --------------------------------------------------------------------


--- --------------------------------------------------------------------
--- writing to data-EEprom, waits till finished
--- --------------------------------------------------------------------
+-- Writes a byte to data eeprom at given address
+-- Waits untill finished
  procedure data_eeprom_write(byte in address, byte in data) is

        var bit gie_old
@@ -91,13 +95,17 @@
        while EECON1_WR loop end loop

  end procedure
--- --------------------------------------------------------------------
+
+-- Writes a word to data eeprom at given address
+-- (based on procedure `data_eeprom_write`)
  procedure data_eeprom_write_word(byte in address, word in data) is
        var byte temp[2] at data
        data_eeprom_write(address,temp[0])
        data_eeprom_write(address+1,temp[1])
  end procedure
--- --------------------------------------------------------------------
+
+-- Writes a dword to data eeprom at given address
+-- (based on procedure `data_eeprom_write`)
  procedure data_eeprom_write_dword(byte in address, dword in data) is
        var byte temp[4] at data
        data_eeprom_write(address,temp[0])
@@ -105,5 +113,4 @@
        data_eeprom_write(address+2,temp[2])
        data_eeprom_write(address+3,temp[3])
  end procedure
--- --------------------------------------------------------------------


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       Sat Sep  6  
02:49:29 2008
@@ -15,32 +15,26 @@

  var byte ccpr1l_shadow
  var byte ccp1con_shadow
---  
-----------------------------------------------------------------------------

---  
-----------------------------------------------------------------------------
--- sets dutycyle in low resolution mode
--- the 2 LSbits take their value from ccp1con_shadow, by default 0
--- this means if duty1 = 0, there's no pwm, if duty1 = 255, you're closed  
to
+-- Sets dutycyle in low resolution mode.
+-- The 2 LSbits take their value from ccp1con_shadow, by default 0
+-- 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
  end procedure
---  
-----------------------------------------------------------------------------


-
---  
-----------------------------------------------------------------------------
  -- sets dutycyle in high resolution mode
  -- the word passed to the procedure represents the high resolution value
  -- of the duty cycle:
---             * duty1h<0:1> are the 2 LSbits
---             * duty1h<2:9> are the 8 MSbits
+--  * duty1h<0:1> are the 2 LSbits
+--  * duty1h<2:9> are the 8 MSbits
+--
  -- Because duty cycle is coded on 10 bits, the given value can't greater  
than 1024
  -- 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
@@ -55,7 +49,6 @@
        ccp1con_shadow = ccp1con_shadow | 0b_0000_1100
        CCP1CON = ccp1con_shadow
  end procedure
---  
-----------------------------------------------------------------------------

  procedure pwm1_on() is
        -- pwm mode on, while keeping 2 LSbits
@@ -121,6 +114,5 @@


  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       Sat Sep  6  
02:49:29 2008
@@ -15,32 +15,26 @@

  var byte ccpr2l_shadow
  var byte ccp2con_shadow
---  
-----------------------------------------------------------------------------

---  
-----------------------------------------------------------------------------
--- sets dutycyle in low resolution mode
--- the 2 LSbits take their value from ccp2con_shadow, by default 0
--- this means if duty2 = 0, there's no pwm, if duty2 = 255, you're closed  
to
+-- Sets dutycyle in low resolution mode.
+-- The 2 LSbits take their value from ccp2con_shadow, by default 0
+-- 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
  end procedure
---  
-----------------------------------------------------------------------------


-
---  
-----------------------------------------------------------------------------
  -- sets dutycyle in high resolution mode
  -- the word passed to the procedure represents the high resolution value
  -- of the duty cycle:
---             * duty2h<0:1> are the 2 LSbits
---             * duty2h<2:9> are the 8 MSbits
+--  * duty2h<0:1> are the 2 LSbits
+--  * duty2h<2:9> are the 8 MSbits
+--
  -- Because duty cycle is coded on 10 bits, the given value can't greater  
than 1024
  -- 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
@@ -55,7 +49,6 @@
        ccp2con_shadow = ccp2con_shadow | 0b_0000_1100
        CCP2CON = ccp2con_shadow
  end procedure
---  
-----------------------------------------------------------------------------

  procedure pwm2_on() is
        -- pwm mode on, while keeping 2 LSbits
@@ -121,6 +114,5 @@


  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       Sat Sep  6  
02:49:29 2008
@@ -15,32 +15,26 @@

  var byte ccpr3l_shadow
  var byte ccp3con_shadow
---  
-----------------------------------------------------------------------------

---  
-----------------------------------------------------------------------------
--- sets dutycyle in low resolution mode
--- the 2 LSbits take their value from ccp3con_shadow, by default 0
--- this means if duty3 = 0, there's no pwm, if duty3 = 255, you're closed  
to
+-- Sets dutycyle in low resolution mode.
+-- The 2 LSbits take their value from ccp3con_shadow, by default 0
+-- 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
  end procedure
---  
-----------------------------------------------------------------------------


-
---  
-----------------------------------------------------------------------------
  -- sets dutycyle in high resolution mode
  -- the word passed to the procedure represents the high resolution value
  -- of the duty cycle:
---             * duty3h<0:1> are the 2 LSbits
---             * duty3h<2:9> are the 8 MSbits
+--  * duty3h<0:1> are the 2 LSbits
+--  * duty3h<2:9> are the 8 MSbits
+--
  -- Because duty cycle is coded on 10 bits, the given value can't greater  
than 1024
  -- 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
@@ -55,7 +49,6 @@
        ccp3con_shadow = ccp3con_shadow | 0b_0000_1100
        CCP3CON = ccp3con_shadow
  end procedure
---  
-----------------------------------------------------------------------------

  procedure pwm3_on() is
        -- pwm mode on, while keeping 2 LSbits
@@ -121,6 +114,5 @@


  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       Sat Sep  6  
02:49:29 2008
@@ -15,32 +15,26 @@

  var byte ccpr4l_shadow
  var byte ccp4con_shadow
---  
-----------------------------------------------------------------------------

---  
-----------------------------------------------------------------------------
--- sets dutycyle in low resolution mode
--- the 2 LSbits take their value from ccp4con_shadow, by default 0
--- this means if duty4 = 0, there's no pwm, if duty4 = 255, you're closed  
to
+-- Sets dutycyle in low resolution mode.
+-- The 2 LSbits take their value from ccp4con_shadow, by default 0
+-- 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
  end procedure
---  
-----------------------------------------------------------------------------


-
---  
-----------------------------------------------------------------------------
  -- sets dutycyle in high resolution mode
  -- the word passed to the procedure represents the high resolution value
  -- of the duty cycle:
---             * duty4h<0:1> are the 2 LSbits
---             * duty4h<2:9> are the 8 MSbits
+--  * duty4h<0:1> are the 2 LSbits
+--  * duty4h<2:9> are the 8 MSbits
+--
  -- Because duty cycle is coded on 10 bits, the given value can't greater  
than 1024
  -- 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
@@ -55,7 +49,6 @@
        ccp4con_shadow = ccp4con_shadow | 0b_0000_1100
        CCP4CON = ccp4con_shadow
  end procedure
---  
-----------------------------------------------------------------------------

  procedure pwm4_on() is
        -- pwm mode on, while keeping 2 LSbits
@@ -121,6 +114,5 @@


  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       Sat Sep  6  
02:49:29 2008
@@ -15,32 +15,26 @@

  var byte ccpr5l_shadow
  var byte ccp5con_shadow
---  
-----------------------------------------------------------------------------

---  
-----------------------------------------------------------------------------
--- sets dutycyle in low resolution mode
--- the 2 LSbits take their value from ccp5con_shadow, by default 0
--- this means if duty5 = 0, there's no pwm, if duty5 = 255, you're closed  
to
+-- Sets dutycyle in low resolution mode.
+-- The 2 LSbits take their value from ccp5con_shadow, by default 0
+-- 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
  end procedure
---  
-----------------------------------------------------------------------------


-
---  
-----------------------------------------------------------------------------
  -- sets dutycyle in high resolution mode
  -- the word passed to the procedure represents the high resolution value
  -- of the duty cycle:
---             * duty5h<0:1> are the 2 LSbits
---             * duty5h<2:9> are the 8 MSbits
+--  * duty5h<0:1> are the 2 LSbits
+--  * duty5h<2:9> are the 8 MSbits
+--
  -- Because duty cycle is coded on 10 bits, the given value can't greater  
than 1024
  -- 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
@@ -55,7 +49,6 @@
        ccp5con_shadow = ccp5con_shadow | 0b_0000_1100
        CCP5CON = ccp5con_shadow
  end procedure
---  
-----------------------------------------------------------------------------

  procedure pwm5_on() is
        -- pwm mode on, while keeping 2 LSbits
@@ -121,6 +114,5 @@


  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     Sat Sep  6  
02:49:29 2008
@@ -16,7 +16,6 @@



---  
-----------------------------------------------------------------------------
  -- initializes the PWM for high resolution (10 bits) and starts the PWM
  -- While setting high resolution, prescaler can be used to adjust  
frequency.
  -- The parameter corresponds to the prescaler value, and can be either:
@@ -29,15 +28,11 @@
  --
  -- FYI, here's a table showing frequency for common clock speed:
  --
--- -----------------+------------+------------+------------+------------+
--- prescaler/clock  |    4MHz    |    8MHz    |   10MHz    |   20MHz    |
--- -----------------+------------+------------+------------+------------+
---     1            |    3.90kHz |    7.81kHz |   9.77kHz  |   19.43kHz |
---     4            |     976Hz  |    1.95kHz |   2.44kHz  |    4.88kHz |
---     16           |     244Hz  |     488Hz  |    610Hz   |    1.22kHz |
--- -----------------+------------+------------+------------+------------+
+-- ||*prescaler/clock* ||   *4MHz*   ||   *8MHz*   ||  *10MHz*   ||   
*20MHz*   ||
+-- ||    1             ||    3.90kHz ||    7.81kHz ||   9.77kHz  ||    
19.43kHz ||
+-- ||    4             ||     976Hz  ||    1.95kHz ||   2.44kHz  ||     
4.88kHz ||
+-- ||    16            ||     244Hz  ||     488Hz  ||    610Hz   ||     
1.22kHz ||
  --
---  
----------------------------------------------------------------------------
  procedure pwm_max_resolution(byte in prescaler) is
        -- set timervalue to maximum resolution
        PR2 = 0xFF
@@ -54,22 +49,19 @@
                ;pragma error  ;pwm frequency is not allowed for high resolution
        end if
  end procedure
---  
-----------------------------------------------------------------------------


--- Store potential PR2 value that could be used to actually
--- perform the accurate frequency
+-- Stores computed PR2 value when prescaler value is 1
+-- Used to compute accurate frequency
  var volatile dword _pr2_1
+-- Stores computed PR2 value when prescaler value is 4
+-- Used to compute accurate frequency
  var volatile dword _pr2_4
+-- Stores computed PR2 value when prescaler value is 16
+-- Used to compute accurate frequency
  var volatile dword _pr2_16

---  
-----------------------------------------------------------------------------
--- initializes the PWM for accurate frequency and starts the PWM
--- Frequency and dutycycle should be set by the following constants
---     const pwm_frequency = 2_000    -- pwm frequency in Hz
---     const pwm1_dutycycle = 50      -- dutycycle in percent of PWM1
---     const pwm2_dutycycle = 50      -- dutycycle in percent of PWM2
---  
-----------------------------------------------------------------------------
+-- 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 )

Modified: trunk/unvalidated/include/peripheral/usart/serial_hardware.jal
==============================================================================
--- trunk/unvalidated/include/peripheral/usart/serial_hardware.jal       
(original)
+++ trunk/unvalidated/include/peripheral/usart/serial_hardware.jal      Sat Sep 
  
6 02:49:29 2008
@@ -19,18 +19,15 @@
  -- TODO: should this be configurable ?
  -- Transmission parameters are 8 databits, 1 stopbit, no parity, no  
handshake.
  --
--- --------------------------------------------------------------------


--- --------------------------------------------------------------------
+
  -- some variables made available under a general (pic-independant) name
--- --------------------------------------------------------------------
+
  var volatile bit serial_hw_data_available is PIR1_RCIF
  var volatile bit serial_hw_data_ready  is PIR1_TXIF
--- --------------------------------------------------------------------


--- --------------------------------------------------------------------
  -- internal function, calculates and sets baudrate divider
  -- and stores it in the appropiate register.
  -- the high-speed / low-speed bit is not stored but returned as the result
@@ -38,18 +35,19 @@
  -- Special attention is payed to the highest and lowest baudrates,
  -- a deviation of 5% is accepted in these cases
  --
--- Asynchronous baudrate settings (see also page 74/75 of DS40300B)
---
+-- Asynchronous baudrate settings (see also page 74/75 of DS40300B):
+-- {{{
  -- if TXSTA_BRGH = 0 (low speed)
  --  SPBRG = ( Fosc / ( 64 * Baudrate ) ) -1
  --
  -- if TXSTA_BRGH = 1 (high speed)
  --  SPBRG = ( Fosc / ( 16 * Baudrate ) ) -1
+-- }}}
+--
+-- Synchronous baudrate settings:
+--  * TXSTA_BRGH = 0 (low speed)
+--  * SPBRG = ( Fosc / ( 4 * Baudrate ) ) -1
  --
--- Synchronous baudrate settings
--- TXSTA_BRGH = 0 (low speed)
---  SPBRG = ( Fosc / ( 4 * Baudrate ) ) -1
--- --------------------------------------------------------------------
  procedure _calculate_and_set_baudrate() is
        const max_deviation = 5  -- maximum % deviation of the realized baudrate

@@ -125,16 +123,13 @@
        end if

  end procedure
--- --------------------------------------------------------------------


--- --------------------------------------------------------------------
  -- Initializes the RS232 port, calculates baudrate registers.
  -- Normally this routine should not be called by the user program,
  -- it's called just once at the end of this unit
  -- Only after "asynch_disable_hw" it's necessary to call this routine,
  -- to enable the RS232 hardware again.
--- --------------------------------------------------------------------
  procedure serial_hw_init() is
        -- Calculate and Load baudrate generator
        _calculate_and_set_baudrate()
@@ -151,53 +146,41 @@
        RCSTA = 0x90

  end procedure
--- --------------------------------------------------------------------


--- --------------------------------------------------------------------
  -- Disables USART (wether used as RS232 or SPI),
  -- so ports can be used (temporary) for other purposes.
  -- USART can be enabled again by calling serial_hw_enable()
--- --------------------------------------------------------------------
  procedure serial_hw_disable() is
        -- wait till running transmissions are finished
        while !TXSTA_TRMT loop end loop
        -- Disable Serial port:
        RCSTA_SPEN = false
  end procedure
--- --------------------------------------------------------------------


--- --------------------------------------------------------------------
  -- Enables USART (wether used as RS232 or SPI),
--- --------------------------------------------------------------------
  procedure serial_hw_enable() is
        -- Enable Serial port
        RCSTA_SPEN = true
  end procedure
--- --------------------------------------------------------------------


--- --------------------------------------------------------------------
  -- Asynchronuous RS232 send routine, using the TX pin
  -- Sends byte X (8 bit with no parity) to the serial port
  -- First checks (and waits if necessary) if transmit buffer is empty
  --
  -- remark: PIR1-register (containing _TXIF-flag) must be in bank0 !!
--- --------------------------------------------------------------------
  procedure serial_hw_write(byte in data) is
        -- wait until TXREG is empty
        while ! PIR1_TXIF loop end loop
        -- then put new byte in TXREG (prepare for transmission)
        TXREG = data
  end procedure
--- --------------------------------------------------------------------


--- --------------------------------------------------------------------
  -- like Serial_H_write, but then with a word as input
  -- The MSB is outputed first
--- --------------------------------------------------------------------
  procedure serial_hw_write_word(word in data) is
        var byte DX[2] at data
        -- can be blocked by debugging
@@ -209,13 +192,10 @@
        while ! PIR1_TXIF loop end loop
        TXREG = DX[0]
  end procedure
--- --------------------------------------------------------------------


--- --------------------------------------------------------------------
  -- Returns true if a character was received, otherwise returns false.
  -- Overrun error flag is cleared.
--- --------------------------------------------------------------------
  function serial_hw_read(byte out data) return bit is
        -- test if byte available, and if so,
        -- get byte and transport to outer world
@@ -232,23 +212,25 @@

        return true
  end function
--- --------------------------------------------------------------------

--- --------------------------------------------------------------------
  -- Here Serial read and write are definied as pseudo variables
  -- so you use them as normal vars, like
---      -- wait for character being received,
---      -- then echo the inverted character
---      serial_hw_data = ! serial_hw_data
+--  * wait for character being received,
+--  * then echo the inverted character
+-- {{{
+-- serial_hw_data = ! serial_hw_data
+-- }}}
  --
  -- these procedures will wait till they can perform their action
--- therefor it's better to use to following construct
---      -- if charater received, echo the inverted character
---      if  serial_hw_data_available then
---        serial_hw_data = ! serial_hw_data
---      end if
---      -- do other things
--- --------------------------------------------------------------------
+-- therefore it's better to use to following construct
+-- {{{
+-- -- if charater received, echo the inverted character
+-- if  serial_hw_data_available then
+--     serial_hw_data = ! serial_hw_data
+-- end if
+-- -- do other things
+-- }}}
+--
  procedure serial_hw_data'put(byte in data) is
        -- -----------------------------------------------
        -- BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG      
@@ -265,14 +247,11 @@
        while ! serial_hw_read(data) loop end loop
        return data
  end function
--- --------------------------------------------------------------------


--- --------------------------------------------------------------------
  -- These are real raw procedures, declared as pseudo variables
  -- the user is totally responsible for testing the transmit/receive
  -- flag before using these functions
--- --------------------------------------------------------------------
  procedure serial_hw_data_raw'put(byte in data) is
        TXREG = data
  end procedure
@@ -280,5 +259,4 @@
  function serial_hw_data_raw'get() return byte is
        return RCREG
  end function
--- --------------------------------------------------------------------


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