Author: sebastien.lelong
Date: Sun Jul 19 11:54:58 2009
New Revision: 1103

Added:
    trunk/sample/16f876a_adc.jal
    trunk/sample/16f877_adc.jal
Modified:
    trunk/CHANGELOG
    trunk/TORELEASE
    trunk/include/peripheral/adc/adc.jal
    trunk/include/peripheral/adc/adc_hardware.jal

Log:
add new ADC libs and samples to next release

Modified: trunk/CHANGELOG
==============================================================================
--- trunk/CHANGELOG     (original)
+++ trunk/CHANGELOG     Sun Jul 19 11:54:58 2009
@@ -22,12 +22,14 @@
   - Minor changes in output formatting (for html doc generation).


-
  externals:
   -

  peripherals:
- -
+ - adc: new ADC libraries available, handles more PICs than previous.
+        set_digital_pin() and set_analog_pin() available for PICs where
+        analog pins are independent (see documentation for more).
+        adc_hardware.jal is being deprecated

  jal extension:
   - extended queue interface and 4 queue's (01 to 04)

Modified: trunk/TORELEASE
==============================================================================
--- trunk/TORELEASE     (original)
+++ trunk/TORELEASE     Sun Jul 19 11:54:58 2009
@@ -173,6 +173,9 @@

  # Peripherals
  include/peripheral/adc/adc_hardware.jal
+include/peripheral/adc/adc_channels.jal
+include/peripheral/adc/adc_clock.jal
+include/peripheral/adc/adc.jal
  include/peripheral/data_eeprom/pic_data_eeprom.jal
  include/peripheral/i2c/i2c_hardware.jal
  include/peripheral/i2c/i2c_hw_slave.jal
@@ -297,6 +300,7 @@
  sample/16f874_blink.jal
  sample/16f874a_blink.jal
  sample/16f876_blink.jal
+sample/16f876a_adc.jal
  sample/16f876a_blink.jal
  sample/16f876a_keyboard_lcd.jal
  sample/16f876a_lcd_hd44780_4_1.jal
@@ -305,6 +309,7 @@
  sample/16f876a_sht.jal
  sample/16f876a_t6603.jal
  sample/16f876a_tc77.jal
+sample/16f877_adc.jal
  sample/16f877_blink.jal
  sample/16f877_pata_hard_disk.jal
  sample/16f877a_blink.jal
@@ -330,6 +335,7 @@
  sample/16f877a_serial_hw_int_cts.jal
  sample/16f877a_serial_print.jal
  sample/16f88_adc_lowres.jal
+sample/16f88_adc_highres.jal
  sample/16f88_blink.jal
  sample/16f88_data_eeprom.jal
  sample/16f88_delay_basic.jal

Modified: trunk/include/peripheral/adc/adc.jal
==============================================================================
--- trunk/include/peripheral/adc/adc.jal        (original)
+++ trunk/include/peripheral/adc/adc.jal        Sun Jul 19 11:54:58 2009
@@ -8,11 +8,13 @@
  --
  -- Description: library to handle ADC peripheral.
  --   - support both low and high resolution mode
---   - support a large number of PICs (see adc_pindef.jal for more):
+--   - support a large number of PICs, with
  --       - ADC pin configuration
  --       - channel selection
  --       - clock selection
  --   - support Vref
+-- --
+-- How to use it ? See http://jallib.blogspot.com for details...
  --
  -- Notes: this is a heavy refactoring/rewriting of original library from  
Stef Mientki.
  -- The main changes are about ADC configuration, which are essentially  
handled in

Modified: trunk/include/peripheral/adc/adc_hardware.jal
==============================================================================
--- trunk/include/peripheral/adc/adc_hardware.jal       (original)
+++ trunk/include/peripheral/adc/adc_hardware.jal       Sun Jul 19 11:54:58 2009
@@ -55,6 +55,8 @@
  --
  -- --  
-----------------------------------------------------------------------------

+_warn "adc_hardware is being deprecated, you should consider using new  
adc.jal library"
+
  include delay

  -- sanity check

Added: trunk/sample/16f876a_adc.jal
==============================================================================
--- (empty file)
+++ trunk/sample/16f876a_adc.jal        Sun Jul 19 11:54:58 2009
@@ -0,0 +1,100 @@
+-- Title: Sample showing how to use adc_library
+-- Author: Sebastien Lelong, Copyright (c) 2008-2009, all rights reserved.
+-- Adapted-by:
+-- Compiler: >=2.4k
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the BSD license  
(http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: this program shows how to use adc library. It regurlarly  
performs an
+-- Analog-to-Digital Conversion, on pin RA0/AN0 and sends the result  
through serial.
+--
+-- Notes: as output, this sample produces characters on a serial link, and  
uses delay library.
+-- First be sure you're able to run serial and delay tests.
+--
+--
+-- Few words about diagram: this program performs ADC on channels AN0, so  
you can measure
+-- any voltage source connected to these channels (no more than 5V please).
+-- To test the whole, you can use a voltage divider:
+--
+--     5V
+--     |
+--     Z
+--     Z R1        -----------
+--     Z           |
+--     |------ AN0-|   PIC
+--     Z           |
+--     Z R2        |
+--     Z
+--     |
+--    GND
+--
+--
+--      - R1=1K, R2=1K: you should get ~127/~512 as ADC value (low/high)
+--      - R1=1K, R2=2.2K: you should get ~175/~704 as ADC value (low/high)
+--
+
+include 16f876a
+-- setup clock running @20MHz
+pragma target OSC HS
+pragma target clock 20_000_000
+-- no watchdog, no LVP
+pragma target WDT  disabled
+pragma target LVP  disabled
+-- We'll start to set all pins as digital
+-- then, using ADC lib, we'll configure needed
+-- ones as analog.
+enable_digital_io()
+
+include print
+include delay
+
+-- ok, now setup serial, we'll use this
+-- to get ADC measures
+const serial_hw_baudrate = 115_200
+include serial_hardware
+serial_hw_init()
+
+
+-- ok, now let's configure ADC
+-- we want to measure using high resolution
+-- (that's our choice, we could use low resolution as well)
+const bit ADC_HIGH_RESOLUTION = high
+-- we said we want 1 analog channel...
+const byte ADC_NCHANNEL = 1
+-- and no voltage reference
+const byte ADC_NVREF = 0
+-- now we can include the library
+include adc
+-- and run the initialization step
+adc_init()
+
+
+-- will periodically send those chars
+var word wmeasure
+var byte bmeasure
+const byte wprefix[] = "Result in high resolution: "
+const byte bprefix[] = "Result in low  resolution: "
+forever loop
+   -- get ADC result, on channel 0
+   -- this means we're currently reading on pin AN0 !
+
+   -- access results in high resolution
+   wmeasure = adc_read(0)
+   -- wmeasure contains the result, as a word (byte*2)
+   print_string(serial_hw_data,wprefix)
+   print_word_dec(serial_hw_data,wmeasure)
+   print_crlf(serial_hw_data)
+
+   -- though we are in high resolution mode,
+   -- we can still get a result as a byte, as though
+   -- it were in low resolution.
+   bmeasure = adc_read_low_res(0)
+   print_string(serial_hw_data,wprefix)
+   print_byte_dec(serial_hw_data,bmeasure)
+   print_crlf(serial_hw_data)
+
+   -- and sleep a litte to prevent flooding serial...
+   delay_1ms(200)
+end loop
+

Added: trunk/sample/16f877_adc.jal
==============================================================================
--- (empty file)
+++ trunk/sample/16f877_adc.jal Sun Jul 19 11:54:58 2009
@@ -0,0 +1,100 @@
+-- Title: Sample showing how to use adc_library
+-- Author: Sebastien Lelong, Copyright (c) 2008-2009, all rights reserved.
+-- Adapted-by:
+-- Compiler: >=2.4k
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the BSD license  
(http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: this program shows how to use adc library. It regurlarly  
performs an
+-- Analog-to-Digital Conversion, on pin RA0/AN0 and sends the result  
through serial.
+--
+-- Notes: as output, this sample produces characters on a serial link, and  
uses delay library.
+-- First be sure you're able to run serial and delay tests.
+--
+--
+-- Few words about diagram: this program performs ADC on channels AN0, so  
you can measure
+-- any voltage source connected to these channels (no more than 5V please).
+-- To test the whole, you can use a voltage divider:
+--             
+--     5V
+--     |
+--     Z
+--     Z R1        -----------
+--     Z           |
+--     |------ AN0-|   PIC
+--     Z           |
+--     Z R2        |
+--     Z
+--     |
+--    GND
+--
+--
+--             - R1=1K, R2=1K: you should get ~127/~512 as ADC value (low/high)
+--             - R1=1K, R2=2.2K: you should get ~175/~704 as ADC value 
(low/high)
+--
+
+include 16f877
+-- setup clock running @20MHz
+pragma target OSC HS
+pragma target clock 20_000_000
+-- no watchdog, no LVP
+pragma target WDT  disabled
+pragma target LVP  disabled
+-- We'll start to set all pins as digital
+-- then, using ADC lib, we'll configure needed
+-- ones as analog.
+enable_digital_io()
+
+include print
+include delay
+
+-- ok, now setup serial, we'll use this
+-- to get ADC measures
+const serial_hw_baudrate = 115_200
+include serial_hardware
+serial_hw_init()
+
+
+-- ok, now let's configure ADC
+-- we want to measure using high resolution
+-- (that's our choice, we could use low resolution as well)
+const bit ADC_HIGH_RESOLUTION = high
+-- we said we want 1 analog channel...
+const byte ADC_NCHANNEL = 1
+-- and no voltage reference
+const byte ADC_NVREF = 0
+-- now we can include the library
+include adc
+-- and run the initialization step
+adc_init()
+
+
+-- will periodically send those chars
+var word wmeasure
+var byte bmeasure
+const byte wprefix[] = "Result in high resolution: "
+const byte bprefix[] = "Result in low  resolution: "
+forever loop
+   -- get ADC result, on channel 0
+   -- this means we're currently reading on pin AN0 !
+
+   -- access results in high resolution
+   wmeasure = adc_read(0)
+   -- wmeasure contains the result, as a word (byte*2)
+   print_string(serial_hw_data,wprefix)
+   print_word_dec(serial_hw_data,wmeasure)
+   print_crlf(serial_hw_data)
+
+   -- though we are in high resolution mode,
+   -- we can still get a result as a byte, as though
+   -- it were in low resolution.
+   bmeasure = adc_read_low_res(0)
+   print_string(serial_hw_data,wprefix)
+   print_byte_dec(serial_hw_data,bmeasure)
+   print_crlf(serial_hw_data)
+
+   -- and sleep a litte to prevent flooding serial...
+   delay_1ms(200)
+end loop
+

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