Revision: 1684
Author: jsuijs
Date: Sat Feb 20 10:03:18 2010
Log: 16f73 samples added
http://code.google.com/p/jallib/source/detail?r=1684

Added:
 /trunk/sample/16f73_i2c_hw_slave_check_bus.jal
 /trunk/sample/16f73_i2c_hw_slave_echo.jal
 /trunk/sample/16f73_i2c_hw_slave_eeprom_simulator.jal
 /trunk/sample/16f73_i2c_hw_slave_msg.jal
 /trunk/sample/16f73_i2c_sw_l1.jal
 /trunk/sample/16f73_i2c_sw_master_check_bus.jal
 /trunk/sample/16f73_i2c_sw_master_echo.jal
 /trunk/sample/16f73_pwm_led.jal
 /trunk/sample/16f73_random.jal
 /trunk/sample/16f73_serial_format.jal
 /trunk/sample/16f73_serial_hardware.jal
 /trunk/sample/16f73_serial_hw_int_cts.jal
 /trunk/sample/16f73_serial_print.jal
 /trunk/sample/16f73_timer0_interval.jal
 /trunk/test/board/board_16f73_js.jal
Modified:
 /trunk/test/jal/test_serial_format.jal

=======================================
--- /dev/null
+++ /trunk/sample/16f73_i2c_hw_slave_check_bus.jal      Sat Feb 20 10:03:18 2010
@@ -0,0 +1,88 @@
+-- Title: Program to test an i2c bus (using i2c hardware slave)
+-- Author: Sebastien Lelong, Copyright (c) 2008-2009, all rights reserved.
+-- Adapted-by:
+-- Compiler: >=2.4i
+--
+-- 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 is a one shot test program. It's used to check if
+-- i2c bus is properly operational. It requires an SSP/i2c enabled PIC
+-- --
+-- The idea is enable Start/Stop interrupts. When master sends something, whatever +-- the address, it should produce an interrupt on this slave. As soon as interrupt +-- is dealt with, a LED is flashing indefinitely (it also slowly blink when PIC is up)
+--
+-- Sources:
+--
+--
+-- This file has been generated from:
+--    * board: board_16f73_js.jal
+--    * test : test_i2c_hw_slave_check_bus.jal
+--
+
+;@jallib section chipdef
+-- chip setup
+include 16f73
+
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target OSC HS               -- HS crystal or resonator
+pragma target clock 20_000_000     -- oscillator frequency
+pragma target WDT  disabled
+enable_digital_io()
+;@jallib section led
+-- LED IO definition
+alias led             is pin_c0
+alias led_direction   is pin_c0_direction
+alias led2            is pin_c1
+alias led2_direction  is pin_c1_direction
+
+-- i2c setup
+-- with Start/Stop interrupts
+const bit i2c_enable_start_stop_interrupts = true
+include i2c_hw_slave
+const SLAVE_ADDRESS = 0x23 -- whatever, it's not important, and can be
+                                                  -- different from the 
address the master wants
+                                                  -- to talk to
+-- this init automatically sets global/peripherals interrupts
+i2c_hw_slave_init(SLAVE_ADDRESS)
+
+
+-- Main ISR
+procedure i2c_isr() is
+   pragma interrupt
+   if ! PIR1_SSPIF then
+      return
+   end if
+   -- reset flag
+   PIR1_SSPIF = false
+   -- tmp store SSPSTAT and mask out unimportant bit
+   var byte tmpstat
+   tmpstat = SSPSTAT
+   -- check start signals
+   if (tmpstat == 0b_1000) then
+         -- If we get there, this means this is an SSP/I2C interrupts
+         -- and this means i2c bus is properly operational !!!
+         while true loop
+            led = on
+            _usec_delay(100000)
+            led = off
+            _usec_delay(100000)
+         end loop
+   end if
+end procedure
+
+-- Blink a little when PIC is up
+led_direction = output
+for 4 loop
+   led = on
+   _usec_delay(250000)
+   led = off
+   _usec_delay(250000)
+end loop
+
+-- waiting for interrupts
+forever loop
+end loop
=======================================
--- /dev/null
+++ /trunk/sample/16f73_i2c_hw_slave_echo.jal   Sat Feb 20 10:03:18 2010
@@ -0,0 +1,134 @@
+-- Title: Test program for i2c hardware slave, stateful implementation
+-- Author: Sebastien Lelong, Copyright (c) 2008-2009, all rights reserved.
+-- Adapted-by: Joep Suijs
+-- Compiler: >=2.4i
+--
+-- 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 sample shows how to implements an i2c hardware slave,
+-- based in i2c_hw_slave_isr.jal library. Basically, this i2c slave waits for +-- a byte, and when required, it sends byte + 1 (send "a", you'll get a "b")
+-- --
+-- This sample is aimed to be used with *_i2c_hw_master_echo.jal samples,
+-- which is the master part.
+--
+--
+--
+-- This file has been generated from:
+--    * board: board_16f73_js.jal
+--    * test : test_i2c_hw_slave_echo.jal
+--
+
+;@jallib section chipdef
+-- chip setup
+include 16f73
+
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target OSC HS               -- HS crystal or resonator
+pragma target clock 20_000_000     -- oscillator frequency
+pragma target WDT  disabled
+;@jallib section led
+-- LED IO definition
+alias led             is pin_c0
+alias led_direction   is pin_c0_direction
+alias led2            is pin_c1
+alias led2_direction  is pin_c1_direction
+led_direction = output
+
+include i2c_hw_slave
+-- this will be the slave address. It looks like:
+--     0b_0101_1100
+-- => 0b_0101_110   : 7-bits address
+-- =>            0  : 8th bit is to specify read or write operation.
+--                    Value can be anything, it does not matter while init
+const byte SLAVE_ADDRESS = 0x5C
+i2c_hw_slave_init(SLAVE_ADDRESS)
+
+-- will store what to send back to master
+-- so if we get "a", we need to store "a" + 1
+var byte data
+
+
+-- Before including i2c_hw_slave_isr library, several callbacks
+-- must be defined (callbacks are procedure which supposed to be defined
+-- and be called on appriopriate time)
+
+-- Since all those callbacks are called once per state (no other calls
+-- in the program), it is suggested to use "pragma inline", to save
+-- stack usage
+
+
+-- this callback is used when something wrong happened
+-- during communication between master and us
+procedure i2c_hw_slave_on_error() is
+   pragma inline
+   -- Just tell user user something's got wrong
+   forever loop
+         led = on
+         _usec_delay(200000)
+         led = off
+         _usec_delay(200000)
+   end loop
+end procedure
+
+
+-- this callback is used when master wants to talk to us
+-- and our i2c address has been recognized
+procedure i2c_hw_slave_on_state_1(byte in _trash) is
+   pragma inline
+   -- _trash is read from master, but it's a dummy data
+   -- usually (always ?) ignored
+end procedure
+
+
+-- This callback is used when master sends a data byte
+procedure i2c_hw_slave_on_state_2(byte in rcv) is
+   pragma inline
+   -- ultimate data processing... :)
+   data = rcv + 1
+end procedure
+
+
+-- this callback is used when master wants to read something
+-- from us. It should use i2c_hw_slave_write() to send something
+procedure i2c_hw_slave_on_state_3() is
+   pragma inline
+   i2c_hw_slave_write_i2c(data)
+end procedure
+
+
+-- this callback is used when master, after having read something,
+-- still wants to read and get data from us.
+procedure i2c_hw_slave_on_state_4() is
+   pragma inline
+   -- This shouldn't occur in our i2c echo example
+   i2c_hw_slave_on_error()
+end procedure
+
+
+-- this callback is used when master does not want to talk
+-- with us anymore... This is an appropriate place to reset
+-- data for instance
+procedure i2c_hw_slave_on_state_5() is
+   pragma inline
+   data = 0
+end procedure
+
+
+-- callbacks are defined, now include ISR
+include i2c_hw_slave_isr
+
+-- blink a little to tell the world we're up
+for 4 loop
+   led = on
+   _usec_delay(100000)
+   led = off
+   _usec_delay(100000)
+end loop
+
+-- just loop until interrupt is raised
+forever loop
+end loop
=======================================
--- /dev/null
+++ /trunk/sample/16f73_i2c_hw_slave_eeprom_simulator.jal Sat Feb 20 10:03:18 2010
@@ -0,0 +1,147 @@
+-- Title: Test program for i2c hardware slave, message interface implementation +-- Author: Joep Suijs, Sebastien Lelong, Copyright (c) 2008-2009, all rights reserved.
+-- Adapted-by:
+-- Compiler: >=2.4i
+--
+-- 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 sample shows how to implements an i2c hardware slave,
+-- using the message interface lib. It has the same interface* as an 24lc256 i2c eeprom +-- and supports 32 bytes of memory. This means it can be used with the i2c master
+-- samples: i2c_sw_l1 and i2c_hw_l1.
+-- --
+-- (* the slave does behave similar as far as the test is concerned. It does however +-- store the data in ram and the memory pointer behaves different, so read without
+-- previous setting the desired address gives unpredictable results.)
+--
+--
+-- This file has been generated from:
+--    * board: board_16f73_js.jal
+--    * test : test_i2c_hw_slave_eeprom_simulator.jal
+--
+
+;@jallib section chipdef
+-- chip setup
+include 16f73
+
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target OSC HS               -- HS crystal or resonator
+pragma target clock 20_000_000     -- oscillator frequency
+pragma target WDT  disabled
+;@jallib section led
+-- LED IO definition
+alias led             is pin_c0
+alias led_direction   is pin_c0_direction
+alias led2            is pin_c1
+alias led2_direction  is pin_c1_direction
+led_direction = output
+
+-- setup serial (see echo.jal for more details);@jallib section serial
+const serial_hw_baudrate = 115_200
+include serial_hardware
+serial_hw_init()
+
+include print
+
+const byte str1[] = "Test i2c hardware slave - msg interface Eeprom sim interface.\r\n" -- define a string
+print_string(serial_hw_data, str1)                 -- output string
+
+-- for debug only!
+-- const bit i2c_debug = true -- value does not care, the existence of the const enables debug
+if(defined(i2c_debug) == true) then
+   const byte  queue01_size = 80
+   include queue01
+   queue01_clear()
+end if
+
+-- ---------------
+-- setup i2c slave
+-- ---------------
+const byte I2C_BUFFER_SIZE = 40
+include i2c_hw_slave_msg
+
+-- this will be the slave address. It looks like:
+--     0b_0101_1100
+-- => 0b_0101_110   : 7-bits address
+-- =>            0  : 8th bit is to specify read or write operation.
+--                    Value can be anything, it does not matter while init
+const byte SLAVE_ADDRESS = 0xA0
+i2c_hw_slave_init(SLAVE_ADDRESS)
+
+
+-- simulated memory
+var volatile byte memory[32];
+var volatile word address_pointer = 0;
+
+-- --------------------------------------------------------------------
+-- i2c_process_message - User code for i2c slave
+-- --------------------------------------------------------------------
+-- This code is called from the ISR, every time the i2c slave module
+-- received a serie of bytes.
+-- The ISR logic assures this procedure is called exactly once for
+-- each messagae.
+-- --------------------------------------------------------------------
+procedure i2c_process_message(byte in byte_count) is
+   var byte i
+
+   if (byte_count >= 2) then
+ -- this should always be the case - we want at least a 2-byte address.
+      address_pointer = word(i2c_buffer[0]) * 256 + word(i2c_buffer[1])
+
+      if (byte_count > 2) then
+         -- there are bytes to store
+         i = 2
+         for (byte_count - 2) loop
+
+            if(defined(i2c_debug) == true) then
+               queue01_nb = "&"
+               print_byte_hex(queue01_nb, i2c_buffer[i])
+            end if
+
+            memory[(address_pointer & 0x1F)] = i2c_buffer[i]
+            i = i + 1
+            address_pointer = address_pointer + 1
+         end loop
+      end if
+
+      -- now prepare buffer in case the master wants to read back
+      for 32 using i loop
+         i2c_buffer[i] = memory[((address_pointer + i)& 0x1F)]
+      end loop
+   end if
+
+end procedure
+
+
+-- blink a little to tell the world we're up
+for 4 loop
+   led = on
+   _usec_delay(100000)
+   led = off
+   _usec_delay(100000)
+end loop
+
+var byte ch
+
+-- just loop until interrupt is raised
+forever loop
+
+   if(defined(i2c_debug) == true) then
+      -- dump data from isr to serial port
+      ch = queue01_nb
+      if (ch != 0) then serial_hw_data = ch end if
+   end if
+
+   if (serial_hw_read(ch) == true) then
+      serial_hw_data = "!"
+      for 32 using ch loop
+         print_byte_hex(serial_hw_data, memory[ch])
+         serial_hw_data = " "
+      end loop
+      print_crlf(serial_hw_data)
+   end if
+
+end loop
=======================================
--- /dev/null
+++ /trunk/sample/16f73_i2c_hw_slave_msg.jal    Sat Feb 20 10:03:18 2010
@@ -0,0 +1,128 @@
+-- Title: Test program for i2c hardware slave, message interface implementation +-- Author: Joep Suijs, Sebastien Lelong, Copyright (c) 2008-2009, all rights reserved.
+-- Adapted-by:
+-- Compiler: >=2.4i
+--
+-- 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 sample shows how to implements an i2c hardware slave,
+-- using the message interface lib. Basically, this i2c slave waits for
+-- a full message to arrive and then calls a user routine to process the message and
+-- (optional) prepare a response.
+-- --
+-- Conventions:
+-- S = create (re)start state
+-- P = create stop state
+-- E4W = master writes 0x4E
+-- R   = master reads and ACKs
+-- N   = master reads and NACKs
+-- --
+-- s5Cw80ws5Dwrnp - reads application code and version (0x31 0x01)
+-- s5Cw90w00wp    - LED off
+-- s5Cw90wFFwp    - LED on
+-- --
+--
+-- This file has been generated from:
+--    * board: board_16f73_js.jal
+--    * test : test_i2c_hw_slave_msg.jal
+--
+
+;@jallib section chipdef
+-- chip setup
+include 16f73
+
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target OSC HS               -- HS crystal or resonator
+pragma target clock 20_000_000     -- oscillator frequency
+pragma target WDT  disabled
+;@jallib section led
+-- LED IO definition
+alias led             is pin_c0
+alias led_direction   is pin_c0_direction
+alias led2            is pin_c1
+alias led2_direction  is pin_c1_direction
+led_direction = output
+
+-- setup serial (see echo.jal for more details);@jallib section serial
+const serial_hw_baudrate = 115_200
+include serial_hardware
+serial_hw_init()
+
+include print
+
+const byte str1[] = "Test i2c hardware slave - msg interface.\r\n" -- define a string
+print_string(serial_hw_data, str1)                 -- output string
+
+-- ---------------
+-- setup i2c slave
+-- ---------------
+const byte I2C_BUFFER_SIZE = 40
+include i2c_hw_slave_msg
+
+-- this will be the slave address. It looks like:
+--     0b_0101_1100
+-- => 0b_0101_110   : 7-bits address
+-- =>            0  : 8th bit is to specify read or write operation.
+--                    Value can be anything, it does not matter while init
+const byte SLAVE_ADDRESS = 0x5C
+i2c_hw_slave_init(SLAVE_ADDRESS)
+
+
+
+-- --------------------------------------------------------------------
+-- i2c_process_message - User code for i2c slave
+-- --------------------------------------------------------------------
+-- This code is called from the ISR, every time the i2c slave module
+-- received a serie of bytes.
+-- The ISR logic assures this procedure is called exactly once for
+-- each messagae.
+-- --------------------------------------------------------------------
+procedure i2c_process_message(byte in byte_count) is
+   if (i2c_buffer[0] == 0x80) then
+
+      if (byte_count == 1) then
+         -- cmd 0x80 - request version
+         i2c_buffer[0]   = 0x3C         -- application code
+         i2c_buffer[1]   = 0x01         -- version
+      end if
+
+   elsif (i2c_buffer[0] == 0x90) then
+
+      if (byte_count == 2) then
+         -- cmd 0x90 - turn LED off or on
+         if (i2c_buffer[1] == 0) then
+            LED = off
+         else
+            LED = on
+         end if
+      elsif (byte_count == 1) then
+         -- cmd 0x90 without params: request for led status
+         if (LED) then
+            i2c_buffer[0] = 0xFF
+         else
+            i2c_buffer[0] = 0x00
+         end if
+      end if
+
+   end if
+
+end procedure
+
+
+
+
+-- blink a little to tell the world we're up
+for 4 loop
+   led = on
+   _usec_delay(100000)
+   led = off
+   _usec_delay(100000)
+end loop
+
+-- just loop until interrupt is raised
+forever loop
+
+end loop
=======================================
--- /dev/null
+++ /trunk/sample/16f73_i2c_sw_l1.jal   Sat Feb 20 10:03:18 2010
@@ -0,0 +1,109 @@
+-- ------------------------------------------------------
+-- Title: Test program for i2c_hardware.jal
+--
+-- Author: Joep Suijs, Copyright (c) 2008..2008, all rights reserved.
+--
+-- Adapted-by:
+--
+-- Compiler: >=2.4g
+--
+-- This file is part of jallib  (http://jallib.googlecode.com)
+-- Released under the BSD license (http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: Level 0 i2c test program
+--    interact with an i2c eeprom using the i2c primitives
+-- --
+-- This file defines a test for JALLIB testing, using a test-board
+--  defined by a BOARD file .
+--
+-- Sources:
+--
+-- Notes:
+--    setup:
+--         an 24lc256 i2c eeprom, connected to the test board i2c pins.
+--         a serial connection to a terminal
+--
+-- ------------------------------------------------------
+--
+-- This file has been generated from:
+--    * board: board_16f73_js.jal
+--    * test : test_i2c_sw_l1.jal
+--
+
+;@jallib section chipdef
+-- chip setup
+include 16f73
+
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target OSC HS               -- HS crystal or resonator
+pragma target clock 20_000_000     -- oscillator frequency
+pragma target WDT  disabled
+;@jallib section i2c
+-- I2C io definition
+alias i2c_scl            is pin_c3
+alias i2c_scl_direction  is pin_c3_direction
+alias i2c_sda            is pin_c4
+alias i2c_sda_direction  is pin_c4_direction
+-- generic setup (see releated examples for more details);@jallib section serial
+const serial_hw_baudrate = 115_200
+include serial_hardware
+serial_hw_init()
+include print
+include delay
+
+-- i2c setup
+const word _i2c_bus_speed = 1 ; * 100kHz
+const bit _i2c_level = true   ; i2c levels (not SMB)
+
+include i2c_software
+;include i2c_hardware
+
+i2c_initialize()
+
+
+var byte i2c_tx_buffer[10]
+var byte i2c_rx_buffer[10]
+
+include i2c_level1
+
+-- we're alive
+const byte str1[] = "Test.\r\n"
+print_string(serial_hw_data, str1)
+
+
+var bit r
+var byte i
+forever loop
+
+   -- Send 2 bytes address to device 0xA0 and then read 3 bytes of data
+   i2c_tx_buffer[0] = 0  -- high byte address within i2c eeprom
+   i2c_tx_buffer[1] = 0  -- low byte address within i2c eeprom
+   r = i2c_send_receive(0xA0, 2, 3)
+
+;   -- same as above
+;   r = i2c_receive_wordaddr(0xA0, 0x0000, 3)
+
+   print_bit_truefalse(serial_hw_data, r)
+   serial_hw_data = " "
+
+   print_byte_hex(serial_hw_data, i2c_rx_buffer[0]);
+   serial_hw_data = " "
+   print_byte_hex(serial_hw_data, i2c_rx_buffer[1]);
+   serial_hw_data = " "
+   print_byte_hex(serial_hw_data, i2c_rx_buffer[2]);
+   serial_hw_data = " "
+
+   -- write part (increment 3rd byte at 0x0002)
+   i2c_tx_buffer[0] = 0  -- high byte address within i2c eeprom
+   i2c_tx_buffer[1] = 2  -- low byte address within i2c eeprom
+   i2c_tx_buffer[2] = i2c_rx_buffer[2] + 1  -- data
+   r = i2c_send_receive(0xA0, 3, 0)
+   print_bit_truefalse(serial_hw_data, r)
+   serial_hw_data = " "
+
+   print_crlf(serial_hw_data)
+
+   delay_100ms(10)
+end loop
=======================================
--- /dev/null
+++ /trunk/sample/16f73_i2c_sw_master_check_bus.jal     Sat Feb 20 10:03:18 2010
@@ -0,0 +1,74 @@
+-- Title: Master part of i2c slave check bus test
+-- Author: Sebastien Lelong, Copyright (c) 2008-2009, all rights reserved.
+-- Adapted-by:
+-- Compiler: >=2.4i
+--
+-- 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 test corresponds to the master part
+-- of i2c hardware slave bus check testing program. It blinks a little,
+-- then send a i2c command, then infinitely loop.
+-- This is a one-shot test, if you want to run it again, reset your PICs
+-- (or switch the power off/on...)
+--
+-- Sources:
+--
+--
+-- This file has been generated from:
+--    * board: board_16f73_js.jal
+--    * test : test_i2c_sw_master_check_bus.jal
+--
+
+;@jallib section chipdef
+-- chip setup
+include 16f73
+
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target OSC HS               -- HS crystal or resonator
+pragma target clock 20_000_000     -- oscillator frequency
+pragma target WDT  disabled
+enable_digital_io()
+
+;@jallib section led
+-- LED IO definition
+alias led             is pin_c0
+alias led_direction   is pin_c0_direction
+alias led2            is pin_c1
+alias led2_direction  is pin_c1_direction
+-- blink a little, then send i2c command
+led_direction = output
+for 8 loop
+   led = on
+   _usec_delay(250000)
+   led = off
+   _usec_delay(250000)
+end loop
+
+;@jallib section i2c
+-- I2C io definition
+alias i2c_scl            is pin_c3
+alias i2c_scl_direction  is pin_c3_direction
+alias i2c_sda            is pin_c4
+alias i2c_sda_direction  is pin_c4_direction-- i2c setup
+const word _i2c_bus_speed = 4 ; 400kHz
+const bit _i2c_level = true   ; i2c levels (not SMB)
+include i2c_software
+i2c_initialize()
+
+var byte i2c_tx_buffer[2]
+var byte i2c_rx_buffer[1]
+include i2c_level1
+var byte icaddress = 0x1F      -- slave address, can be anything
+
+-- go! If slave starts to flash at high speed,
+-- it works !
+-- dummy command
+i2c_tx_buffer[0] = "."
+var bit _trash = i2c_send_receive(icaddress, 1, 1)
+
+forever loop
+   -- reached the end of test
+end loop
=======================================
--- /dev/null
+++ /trunk/sample/16f73_i2c_sw_master_echo.jal  Sat Feb 20 10:03:18 2010
@@ -0,0 +1,83 @@
+-- Title: Master part of i2c slave echo
+-- Author: Sebastien Lelong, Copyright (c) 2008-2009, all rights reserved.
+-- Adapted-by:
+-- Compiler: >=2.4i
+--
+-- 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 test corresponds to the master part
+-- of i2c hardware slave echo test (test_i2c_hardware_slave_echo.jal)
+-- While the slave is an hardare i2c, this master uses i2c software,
+-- so it can be run on any PIC.
+-- --
+-- Basically, this test collects chars from a PC via a serial link,
+-- and sends them to the i2c slave. It then reads the results from the slave. +-- Since the slave is supposed to echo the char + 1, if you type "a", you should
+-- get "b". How great :)
+--
+-- Sources:
+--
+--
+-- This file has been generated from:
+--    * board: board_16f73_js.jal
+--    * test : test_i2c_sw_master_echo.jal
+--
+
+;@jallib section chipdef
+-- chip setup
+include 16f73
+
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target OSC HS               -- HS crystal or resonator
+pragma target clock 20_000_000     -- oscillator frequency
+pragma target WDT  disabled
+;@jallib section i2c
+-- I2C io definition
+alias i2c_scl            is pin_c3
+alias i2c_scl_direction  is pin_c3_direction
+alias i2c_sda            is pin_c4
+alias i2c_sda_direction  is pin_c4_direction-- i2c setup
+const word _i2c_bus_speed = 4 ; 400kHz
+const bit _i2c_level = true   ; i2c levels (not SMB)
+include i2c_software
+i2c_initialize()
+
+const single_byte_tx_buffer = 1
+var byte i2c_tx_buffer[1]
+var byte i2c_rx_buffer[1]
+include i2c_level1
+
+
+-- generic setup (see releated examples for more details);@jallib section serial
+const serial_hw_baudrate = 115_200
+include serial_hardware
+serial_hw_init()
+-- Tell the world we're ready !
+serial_hw_write("!")
+
+
+var byte pc_char
+var byte ic_char
+-- Slave address, 8-bits long
+-- The LSb bit is corresponding to read/write operation
+-- It can be either 0 or 1, since it's the i2c library
+-- which will handle this, not you !
+-- Note: must be exactly the same as in slave's code
+var byte icaddress = 0x5C      -- slave address
+
+forever loop
+   if serial_hw_read(pc_char)
+   then
+      serial_hw_write(pc_char) -- echo
+      -- transmit to slave
+      -- we want to send 1 byte, and receive 1 from the slave
+      i2c_tx_buffer[0] = pc_char
+      var bit _trash = i2c_send_receive(icaddress, 1, 1)
+      -- receive buffer should contain our result
+      ic_char = i2c_rx_buffer[0]
+      serial_hw_write(ic_char)
+   end if
+end loop
=======================================
--- /dev/null
+++ /trunk/sample/16f73_pwm_led.jal     Sat Feb 20 10:03:18 2010
@@ -0,0 +1,58 @@
+-- Title: Test program for 1 PWM channel, using a LED
+-- Author: Sebastien Lelong, Copyright (c) 2008-2010, all rights reserved.
+-- Adapted-by: Joep Suijs
+-- Compiler: >=2.4i
+--
+-- 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 sample show how to use PWM in low resolution mode.
+-- It progressively light up and down a LED. Sweet...
+--
+--
+-- This file has been generated from:
+--    * board: board_16f73_js.jal
+--    * test : test_pwm_led.jal
+--
+
+
+;@jallib section chipdef
+-- chip setup
+include 16f73
+
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target OSC HS               -- HS crystal or resonator
+pragma target clock 20_000_000     -- oscillator frequency
+pragma target WDT  disabled
+
+enable_digital_io()
+
+-- Configure PWM
+pin_ccp1_direction = output
+include pwm_hardware
+pwm_max_resolution(1)
+pwm1_on()
+
+forever loop
+   var byte i
+   i = 0
+   -- loop up and down, to produce different duty cycle
+   while i < 250 loop
+      pwm1_set_dutycycle(i)
+      _usec_delay(10000)
+      i = i + 1
+   end loop
+   while i > 0 loop
+      pwm1_set_dutycycle(i)
+      _usec_delay(10000)
+      i = i - 1
+   end loop
+   -- turning off, the LED lights at max.
+   _usec_delay(500000)
+   pwm1_off()
+   _usec_delay(500000)
+   pwm1_on()
+
+end loop
=======================================
--- /dev/null
+++ /trunk/sample/16f73_random.jal      Sat Feb 20 10:03:18 2010
@@ -0,0 +1,89 @@
+-- ------------------------------------------------------
+-- Title: Test program for random.jal
+--
+-- Author: Joep Suijs, Copyright (c) 2008..2008, all rights reserved.
+--
+-- Adapted-by:
+--
+-- Compiler: >=2.4g
+--
+-- This file is part of jallib  (http://jallib.googlecode.com)
+-- Released under the BSD license (http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: Test program
+--
+-- Sources:
+--
+-- Notes: as output, this sample produces characters on a serial link. First
+--        run serial tests to make sure serial comms works okay.
+--
+-- ------------------------------------------------------
+--
+-- This file has been generated from:
+--    * board: board_16f73_js.jal
+--    * test : test_random.jal
+--
+
+;@jallib section chipdef
+-- chip setup
+include 16f73
+
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target OSC HS               -- HS crystal or resonator
+pragma target clock 20_000_000     -- oscillator frequency
+pragma target WDT  disabled
+;@jallib section led
+-- LED IO definition
+alias led             is pin_c0
+alias led_direction   is pin_c0_direction
+alias led2            is pin_c1
+alias led2_direction  is pin_c1_direction
+led_direction = output
+
+include delay
+
+-- set all IO as digital
+enable_digital_io()
+
+
+-- setup serial (see echo.jal for more details);@jallib section serial
+const serial_hw_baudrate = 115_200
+include serial_hardware
+serial_hw_init()
+
+include print
+
+-- RANDOM --
+-- The random provides a decent random function.
+-- If you don't need proper random and need to save on memory
+-- or cpu cycles, you could uncomment the line below. It will
+-- save you 4 bytes of ram and about 80 bytes of program memory.
+-- But: the random output will be of a much less quality!
+;const random_downgrade = 1 -- if this constant exists (even with value 0),
+                              -- the random functions are downgraded
+
+-- include random lib
+include random
+
+var word tmp_word
+
+forever loop
+   delay_100ms( 5 )
+   LED = high
+   delay_100ms( 5 )
+   LED = low
+
+   for 100 loop
+      -- print 100 random words
+      tmp_word = random_word()  -- get 16-bit random number
+      print_word_dec(serial_hw_data, tmp_word)
+   end loop
+
+   print_crlf(serial_hw_data)                      -- empty line
+ print_byte_dec(serial_hw_data, random_byte()) -- get 8-bit random number and output it.
+   print_crlf(serial_hw_data)
+
+end loop
+
=======================================
--- /dev/null
+++ /trunk/sample/16f73_serial_format.jal       Sat Feb 20 10:03:18 2010
@@ -0,0 +1,183 @@
+-- ------------------------------------------------------
+-- Title: Test program for format.jal
+-- Author: Joep Suijs, Copyright (c) 2008..2008, all rights reserved.
+-- Adapted-by:
+-- Compiler: >=2.4g
+--
+-- This file is part of jallib  (http://jallib.googlecode.com)
+-- Released under the BSD license (http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: Test program
+--
+-- Sources:
+--
+-- Notes: as output, this sample produces characters on a serial link. First
+--        run serial tests to make sure serial comms works okay.
+--
+-- ------------------------------------------------------
+--
+-- This file has been generated from:
+--    * board: board_16f73_js.jal
+--    * test : test_serial_format.jal
+--
+
+;@jallib section chipdef
+-- chip setup
+include 16f73
+
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target OSC HS               -- HS crystal or resonator
+pragma target clock 20_000_000     -- oscillator frequency
+pragma target WDT  disabled
+;@jallib section led
+-- LED IO definition
+alias led             is pin_c0
+alias led_direction   is pin_c0_direction
+alias led2            is pin_c1
+alias led2_direction  is pin_c1_direction
+include delay
+
+-- set all IO as digital
+enable_digital_io()
+
+-- ok, now setup serial
+const usart_hw_serial = true -- true = RS232, false = SPI;@jallib section serial
+const serial_hw_baudrate = 115_200
+include serial_hardware
+serial_hw_init()
+
+include format
+
+procedure plingcrlf() is
+   serial_hw_data = "!"
+   serial_hw_data = 13
+   serial_hw_data = 10
+end procedure
+
+procedure line() is
+   for 20 loop
+      serial_hw_data = "-"
+   end loop
+   serial_hw_data = 13
+   serial_hw_data = 10
+end procedure
+
+forever loop                                  -- loop forever
+
+ serial_hw_data = "T" serial_hw_data = "e" serial_hw_data = "s" serial_hw_data = "t" serial_hw_data = ":" serial_hw_data = " "
+   plingcrlf()
+ line() -- --------------------------------------------------------------------
+
+   -- hex byte output
+   format_byte_hex(serial_hw_data, 0xEA)
+   plingcrlf()
+
+   -- hex word output
+   format_word_hex(serial_hw_data, 0xFD22) -- VIC20 reset vector ;-)
+   plingcrlf()
+
+   -- hex word output
+   format_dword_hex(serial_hw_data, 0x12345678)
+   plingcrlf()
+ line() -- --------------------------------------------------------------------
+
+   -- decimal output ' 1.2'
+   format_byte_dec(serial_hw_data, 12, 3, 1)
+   plingcrlf()
+
+   -- decimal output '0.12'
+   format_byte_dec(serial_hw_data, 12, 3, 2)
+   plingcrlf()
+
+   -- decimal output ' 12'
+   format_byte_dec(serial_hw_data, 12, 3, 0)
+   plingcrlf()
+
+   -- decimal output '12.0'
+   format_byte_dec(serial_hw_data, 120, 3, 1)
+   plingcrlf()
+ line() -- --------------------------------------------------------------------
+
+   -- decimal output '-12'
+   format_sbyte_dec(serial_hw_data, -12, 4, 0)
+   plingcrlf()
+
+   -- decimal output '-1.2'
+   format_sbyte_dec(serial_hw_data, -12, 4, 1)
+   plingcrlf()
+
+   -- decimal output '-0.12'
+   format_sbyte_dec(serial_hw_data, -12, 4, 2)
+   plingcrlf()
+
+   -- decimal output '-12'
+   format_sbyte_dec(serial_hw_data,  12, 4, 0)
+   plingcrlf()
+
+   -- decimal output '-1.2'
+   format_sbyte_dec(serial_hw_data,  12, 4, 1)
+   plingcrlf()
+
+   -- decimal output '-0.12'
+   format_sbyte_dec(serial_hw_data,  12, 4, 2)
+   plingcrlf()
+ line() -- --------------------------------------------------------------------
+
+   -- decimal output '-12'
+   format_sbyte_dec(serial_hw_data, -123, 3, 0)
+   plingcrlf()
+
+   -- decimal output '-1.2'
+   format_sbyte_dec(serial_hw_data, -123, 3, 1)
+   plingcrlf()
+
+   -- decimal output '-0.12'
+   format_sbyte_dec(serial_hw_data, -123, 3, 2)
+   plingcrlf()
+
+   -- decimal output '-12'
+   format_sbyte_dec(serial_hw_data,  113, 3, 0)
+   plingcrlf()
+
+   -- decimal output '-1.2'
+   format_sbyte_dec(serial_hw_data,  113, 3, 1)
+   plingcrlf()
+
+   -- decimal output '-0.12'
+   format_sword_dec(serial_hw_data,  765, 3, 2)
+   plingcrlf()
+ line() -- --------------------------------------------------------------------
+
+   -- decimal output ' 0.012'
+   format_word_dec(serial_hw_data, 12, 6, 3)
+   plingcrlf()
+
+   -- decimal output '   1.2'
+   format_word_dec(serial_hw_data, 12, 6, 1)
+   plingcrlf()
+
+   -- decimal output '   12'
+   format_word_dec(serial_hw_data, 12, 6, 0)
+   plingcrlf()
+
+   -- decimal output ' -0.012'
+   format_sword_dec(serial_hw_data, -12, 6, 3)
+   plingcrlf()
+
+   -- decimal output '23:55'
+   format_time_hm(serial_hw_data, 23, 55)  -- 5 minutes to midnight
+   plingcrlf()
+
+   -- decimal output '23:56'
+ format_time_hm_word(serial_hw_data, 23 * 60 + 56) -- 4 minutes to midnight
+   plingcrlf()
+
+   serial_hw_data = "E"    serial_hw_data = "n"    serial_hw_data = "d"
+   plingcrlf()
+   plingcrlf()
+
+   delay_100ms(30)
+
+end loop
=======================================
--- /dev/null
+++ /trunk/sample/16f73_serial_hardware.jal     Sat Feb 20 10:03:18 2010
@@ -0,0 +1,89 @@
+-- ------------------------------------------------------
+-- Title: Test program for serial_hardware.jal
+--
+-- Author: Joep Suijs, Copyright (c) 2008..2008, all rights reserved.
+--
+-- Adapted-by:
+--
+-- Compiler: >=2.4g
+--
+-- This file is part of jallib  (http://jallib.googlecode.com)
+-- Released under the BSD license (http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: Test program for serial hardware lib
+-- --
+-- This file defines a test for JALLIB testing, using a test-board
+--  defined by a BOARD file .
+--
+-- Sources:
+--
+-- Notes:
+--    setup: a serial connection to a terminal
+--
+-- ------------------------------------------------------
+--
+-- This file has been generated from:
+--    * board: board_16f73_js.jal
+--    * test : test_serial_hardware.jal
+--
+
+;@jallib section chipdef
+-- chip setup
+include 16f73
+
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target OSC HS               -- HS crystal or resonator
+pragma target clock 20_000_000     -- oscillator frequency
+pragma target WDT  disabled
+;@jallib section led
+-- LED IO definition
+alias led             is pin_c0
+alias led_direction   is pin_c0_direction
+alias led2            is pin_c1
+alias led2_direction  is pin_c1_direction
+
+include delay
+
+-- set all IO as digital
+enable_digital_io()
+
+-- ok, now setup serial;@jallib section serial
+const serial_hw_baudrate = 115_200
+include serial_hardware
+serial_hw_init()
+
+include print                       -- output library
+
+led_direction = output
+for 4 loop
+   LED = on
+   delay_100ms(3)
+   LED = off
+   delay_100ms(3)
+end loop
+
+
+
+const byte str1[] = "Hello serial world"   -- define a string
+print_string(serial_hw_data, str1)  -- output string to serial
+
+-- inform user PIC is ready !
+serial_hw_write("!")
+
+-- let's build our loop
+var byte char  -- will store received char
+var word counter = 10
+forever loop
+       if serial_hw_read(char) then
+               serial_hw_write(char)   -- that's the echo...
+       end if
+
+       counter = counter - 1;
+       if (counter == 0) then
+          counter = 50000
+      serial_hw_data = "."
+      LED = ! LED
+   end if
+end loop
=======================================
--- /dev/null
+++ /trunk/sample/16f73_serial_hw_int_cts.jal   Sat Feb 20 10:03:18 2010
@@ -0,0 +1,104 @@
+-- ------------------------------------------------------
+-- Title: Test program for serial_hw_int_cts.jal
+--
+-- Author: Joep Suijs, Copyright (c) 2008..2008, all rights reserved.
+--
+-- Adapted-by: Albert Faber
+--
+-- Compiler: >=2.4l
+--
+-- This file is part of jallib  (http://jallib.googlecode.com)
+-- Released under the BSD license (http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: test program for serial hardware lib using interrutps.
+-- --
+-- This file defines a test for JALLIB testing, using a test-board
+--  defined by a BOARD file .
+--
+-- Sources:
+--
+-- Notes:
+--    setup: a serial connection to a terminal
+--
+-- ------------------------------------------------------
+--
+-- This file has been generated from:
+--    * board: board_16f73_js.jal
+--    * test : test_serial_hw_int_cts.jal
+--
+
+;@jallib section chipdef
+-- chip setup
+include 16f73
+
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target OSC HS               -- HS crystal or resonator
+pragma target clock 20_000_000     -- oscillator frequency
+pragma target WDT  disabled
+;@jallib section led
+-- LED IO definition
+alias led             is pin_c0
+alias led_direction   is pin_c0_direction
+alias led2            is pin_c1
+alias led2_direction  is pin_c1_direction
+
+include delay
+
+-- set all IO as digital
+enable_digital_io()
+
+-- ok, now setup serial;@jallib section serial
+const serial_hw_baudrate = 115_200
+alias serial_ctsinv  is  pin_B4        -- incoming data flow control
+var  bit serial_overflow_discard = true   -- With transmit buffer overflow
+
+include serial_hw_int_cts
+serial_hw_init()
+
+include print                       -- output library
+
+led_direction = output
+for 4 loop
+   LED = on
+   delay_100ms(3)
+   LED = off
+   delay_100ms(3)
+end loop
+
+
+
+const byte str1[] = "Hello serial world\r\n"   -- define a string
+print_string(serial_hw_data, str1)  -- output string to serial
+
+-- inform user PIC is ready !
+serial_hw_write("!")
+
+-- let's build our loop
+var byte char  -- will store received char
+var word counter = 10
+forever loop
+       if serial_hw_read(char) then
+
+      if (char == " ") then
+         -- space triggers large output
+         for 40 loop
+            var byte i
+            for 9 using i loop
+               serial_hw_data = i | 0x30
+            end loop
+         end loop
+         counter = 50000  -- restart timeout (don't let the dot interfere)
+      else
+               serial_hw_write(char)   -- that's the echo...
+      end if
+       end if
+
+       counter = counter - 1;
+       if (counter == 0) then
+          counter = 50000
+      serial_hw_data = "."
+      LED = ! LED
+   end if
+end loop
=======================================
--- /dev/null
+++ /trunk/sample/16f73_serial_print.jal        Sat Feb 20 10:03:18 2010
@@ -0,0 +1,206 @@
+-- ------------------------------------------------------
+-- Title: Test program for print.jal
+--
+-- Author: Joep Suijs, Copyright (c) 2008..2008, all rights reserved.
+--
+-- Adapted-by:
+--
+-- Compiler: >=2.4g
+--
+-- This file is part of jallib  (http://jallib.googlecode.com)
+-- Released under the BSD license (http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: Test program
+--
+-- Sources:
+--
+-- Notes: as output, this sample produces characters on a serial link. First
+--        run serial tests to make sure serial comms works okay.
+--
+-- ------------------------------------------------------
+--
+-- This file has been generated from:
+--    * board: board_16f73_js.jal
+--    * test : test_serial_print.jal
+--
+
+;@jallib section chipdef
+-- chip setup
+include 16f73
+
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target OSC HS               -- HS crystal or resonator
+pragma target clock 20_000_000     -- oscillator frequency
+pragma target WDT  disabled
+;@jallib section led
+-- LED IO definition
+alias led             is pin_c0
+alias led_direction   is pin_c0_direction
+alias led2            is pin_c1
+alias led2_direction  is pin_c1_direction
+
+include delay
+
+-- set all IO as digital
+enable_digital_io()
+
+
+-- setup serial (see echo.jal for more details);@jallib section serial
+const serial_hw_baudrate = 115_200
+include serial_hardware
+serial_hw_init()
+
+
+include format
+include print
+
+
+led_direction = output
+
+forever loop
+   delay_100ms( 5 )
+   LED = high
+   delay_100ms( 5 )
+   LED = low
+
+   -- serial_hw_data is a pseudo-var of the desired output-device.
+   serial_hw_data = "A" -- output an A to the serial port.
+
+   --
+ -- The print_* and format_* routines assing the output chars to this pseudo-var.
+   --
+
+   -- output the string, the pseudo var is the first param.
+   const byte str1[] = " - Test print.jal- bytes\r\n"   -- define a string
+   print_string(serial_hw_data, str1)                 -- output string
+-- print_string(serial_hw_data, " - Test print.jal- bytes\r\n") -- output string (not yet supported by JAL)
+
+   -- -----------
+   -- byte stuff
+   -- -----------
+   var  byte a =  210
+   var sbyte b = -109
+
+ print_byte_dec(serial_hw_data, a) -- output in (unsigned) decimal format + print_crlf(serial_hw_data) -- output Carriage Return and Linefeed (0x0D 0x0A), new line
+   print_byte_hex(serial_hw_data, a)   -- output in hex format
+   print_crlf(serial_hw_data)
+   print_byte_binary(serial_hw_data, a)   -- output in binary format
+   print_crlf(serial_hw_data)
+
+   print_sbyte_dec(serial_hw_data, b)   -- output in signed decimal format
+   print_crlf(serial_hw_data)
+
+
+   -- -----------
+   -- word stuff
+   -- -----------
+   const byte str2[] = "Test print.jal - words\r\n"   -- define a string
+   print_string(serial_hw_data, str2)
+
+   var  word c =  45678
+   var sword d = -32109
+
+ print_word_dec(serial_hw_data, c) -- output in (unsigned) decimal format + print_crlf(serial_hw_data) -- output Carriage Return and Linefeed (0x0D 0x0A), new line
+   print_word_hex(serial_hw_data, c)   -- output in hex format
+   print_crlf(serial_hw_data)
+   print_word_binary(serial_hw_data, c)   -- output in binary format
+   print_crlf(serial_hw_data)
+
+   print_sword_dec(serial_hw_data, d)   -- output in signed decimal format
+   print_crlf(serial_hw_data)
+
+   -- -----------
+   -- dword stuff
+   -- -----------
+   const byte str3[] = "Test print.jal - dwords\r\n"   -- define a string
+   print_string(serial_hw_data, str3)
+
+   var  dword e =  3210987654
+   var sdword f = -2109876543
+
+ print_dword_dec(serial_hw_data, e) -- output in (unsigned) decimal format + print_crlf(serial_hw_data) -- output Carriage Return and Linefeed (0x0D 0x0A), new line
+   print_dword_hex(serial_hw_data, e)   -- output in hex format
+   print_crlf(serial_hw_data)
+   print_dword_binary(serial_hw_data, e)   -- output in binary format
+   print_crlf(serial_hw_data)
+
+   print_sdword_dec(serial_hw_data, f)   -- output in signed decimal format
+   print_crlf(serial_hw_data)
+
+   -- -----------
+   -- bit stuff
+   -- -----------
+   const byte str4[] = "Test print.jal - bit\r\n"   -- define a string
+   print_string(serial_hw_data, str4)
+
+   var bit g = 1
+
+   print_bit_10(serial_hw_data, g)           -- output 0 or 1
+   serial_hw_data = " "                      -- output a space
+
+   print_bit_highlow(serial_hw_data, g)      -- output text 'high' or 'low'
+   serial_hw_data = " "                      -- output a space
+
+ print_bit_truefalse(serial_hw_data, g) -- output text 'true' or 'false'
+   serial_hw_data = " "                      -- output a space
+
+   g = 0
+
+   print_bit_10(serial_hw_data, g)           -- output 0 or 1
+   serial_hw_data = " "                      -- output a space
+
+   print_bit_highlow(serial_hw_data, g)      -- output text 'high' or 'low'
+   serial_hw_data = " "                      -- output a space
+
+ print_bit_truefalse(serial_hw_data, g) -- output text 'true' or 'false'
+
+   print_crlf(serial_hw_data)
+
+
+   -- -------------
+   -- and together:
+   -- -------------
+
+   var byte x = "y"
+   const byte str5[] = "Variable x has decimal value "
+   print_string(serial_hw_data, str5)
+   print_byte_dec(serial_hw_data, x)
+
+   const byte str6[] = " which is hex value "
+   print_string(serial_hw_data, str6)
+   print_byte_hex(serial_hw_data, x)
+
+   const byte str7[] = " and represents ASCII character "
+   print_string(serial_hw_data, str7)
+   serial_hw_data = x
+
+   print_crlf(serial_hw_data)
+   print_crlf(serial_hw_data)
+
+end loop
+
+
+
+-- A - Test print.jal- bytes
+-- 210
+-- D2
+-- 11010010
+-- -109
+-- Test print.jal - words
+-- 45678
+-- B26E
+-- 1011001001101110
+-- -32109
+-- Test print.jal - dwords
+-- 3210987654
+-- BF63C886
+-- 10111111011000111100100010000110
+-- -2109876543
+-- Test print.jal - bit
+-- 1 high true 0 low false
+-- Variable x has decimal value 121 which is hex value 79 and represents ASCII character y
=======================================
--- /dev/null
+++ /trunk/sample/16f73_timer0_interval.jal     Sat Feb 20 10:03:18 2010
@@ -0,0 +1,72 @@
+-- Title: test timer0 interval
+--
+-- Author: Joep Suijs, Copyright (c) 2008, all rights reserved.
+-- Adapted-by:
+-- Compiler: >=2.4g
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the BSD license (http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: test the library timero_isr_interval
+-- --
+-- This file defines a test for JALLIB testing, using a test-board
+--  defined by a BOARD file .
+--
+-- Notes:
+--
+--
+-- This file has been generated from:
+--    * board: board_16f73_js.jal
+--    * test : test_timer0_interval.jal
+--
+
+;@jallib section chipdef
+-- chip setup
+include 16f73
+
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target OSC HS               -- HS crystal or resonator
+pragma target clock 20_000_000     -- oscillator frequency
+pragma target WDT  disabled
+;@jallib section led
+-- LED IO definition
+alias led             is pin_c0
+alias led_direction   is pin_c0_direction
+alias led2            is pin_c1
+alias led2_direction  is pin_c1_direction
+
+led_direction = output
+led2_direction = output
+
+-- set all IO as digital
+enable_digital_io()
+
+-- setup the timer0_isr_interval library
+const timer0_isr_rate = 1000  -- 1 kHz isr rate
+const DELAY_SLOTS = 2         -- support 2 delays at the same time
+include timer0_isr_interval
+timer0_isr_init()             -- init timer0 isr
+
+var word prev_isr_counter
+
+   forever loop
+
+      if (isr_counter != prev_isr_counter) then
+         prev_isr_counter = isr_counter
+         -- put here code that you want
+         -- to execute each tick.
+      end if ; 1 kHz loop
+
+      if (check_delay(0)) then
+         set_delay(0, 409) -- 409 ticks on delay-slot 0
+         led = !led
+      end if
+      if (check_delay(1)) then
+         set_delay(1, 619) -- 619 ticks on delay-slot 1
+         led2 = !led2
+      end if
+   end loop
+
+; end of main
=======================================
--- /dev/null
+++ /trunk/test/board/board_16f73_js.jal        Sat Feb 20 10:03:18 2010
@@ -0,0 +1,53 @@
+-- ------------------------------------------------------
+-- Title: BOARD FILE for [see filename]
+-- Author: Joep Suijs, Copyright (c) 2008..2008, all rights reserved.
+-- Adapted-by:
+-- Compiler: >=2.4l
+--
+-- 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 file defines the configuration of a specific test-board.
+-- --
+-- BOARD DESCRIPTION
+-- -----------------
+-- --
+-- * 20 MHz resonator
+-- --
+--
+-- Sources:
+--
+-- Notes:
+--
+-- ------------------------------------------------------
+
+-- This board is used as a reference while generating samples
+;@jallib preferred
+
+;@jallib section chipdef
+-- chip setup
+include 16f73
+
+--
+-- This program assumes a 20 MHz resonator or crystal
+-- is connected to pins OSC1 and OSC2.
+pragma target OSC HS               -- HS crystal or resonator
+pragma target clock 20_000_000     -- oscillator frequency
+pragma target WDT  disabled
+
+;@jallib section led
+-- LED IO definition
+alias led             is pin_c0
+alias led_direction   is pin_c0_direction
+alias led2            is pin_c1
+alias led2_direction  is pin_c1_direction
+
+;@jallib section serial
+const serial_hw_baudrate = 115_200
+
+;@jallib section i2c
+-- I2C io definition
+alias i2c_scl            is pin_c3
+alias i2c_scl_direction  is pin_c3_direction
+alias i2c_sda            is pin_c4
+alias i2c_sda_direction  is pin_c4_direction
=======================================
--- /trunk/test/jal/test_serial_format.jal      Sun Mar 15 10:24:52 2009
+++ /trunk/test/jal/test_serial_format.jal      Sat Feb 20 10:03:18 2010
@@ -93,15 +93,15 @@
    format_sbyte_dec(serial_hw_data, -12, 4, 2)
    plingcrlf()

-   -- decimal output '-12'
+   -- decimal output ' 12'
    format_sbyte_dec(serial_hw_data,  12, 4, 0)
    plingcrlf()

-   -- decimal output '-1.2'
+   -- decimal output ' 1.2'
    format_sbyte_dec(serial_hw_data,  12, 4, 1)
    plingcrlf()

-   -- decimal output '-0.12'
+   -- decimal output ' 0.12'
    format_sbyte_dec(serial_hw_data,  12, 4, 2)
    plingcrlf()
line() -- --------------------------------------------------------------------

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