Revision: 1656
Author: robhamerling
Date: Sun Feb  7 05:54:33 2010
Log: Added 2 samples of serial communications with 16F1937
- one with serial_hardware library, internal oscillator (at 8 MHz) with PLL: 32 MHz
 - one with serial_hw_in_cts library and HS oscillator (16 MHz)


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

Added:
 /trunk/sample/16f1937_serial_hardware.jal
 /trunk/sample/16f1937_serial_hw_int_cts.jal
Modified:
 /trunk/CHANGELOG
 /trunk/TORELEASE

=======================================
--- /dev/null
+++ /trunk/sample/16f1937_serial_hardware.jal   Sun Feb  7 05:54:33 2010
@@ -0,0 +1,60 @@
+-- ------------------------------------------------------
+-- Title: Sample echo program for serial_hardware.jal for 16F1937
+--
+-- Author: Rob Hamerling, Copyright (c) 2008..2010, all rights reserved.
+--
+-- Adapted-by:
+--
+-- Compiler: 2.4n
+--
+-- This file is part of jallib  (http://jallib.googlecode.com)
+-- Released under the BSD license (http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description:
+-- Sample use of serial_hw_int_cts library for PIC16F1937
+-- Echoes all data received from the serial interface.
+-- Input flow control by CTS signalling makes sure buffer will not be overflowed
+-- (provided the sender has CTS output flow control enabled!)
+--
+-- Sources:
+--
+-- Notes: Uses internal oscillator at 8 MHz with PLL enabled (32 MHz)
+--
+-- ------------------------------------------------------
+
+include 16f1937
+
+pragma target   clock  32_000_000           -- osc frequency
+pragma target   OSC    INTOSC_NOCLKOUT      -- internal oscillator
+pragma target   WDT    disabled             -- no watchdog
+pragma target   PWRTE  enabled              -- powerup delay
+pragma target   LVP    disabled             -- no low voltage programming
+pragma target   DEBUG  disabled             -- no debug
+pragma target   PLLEN  P4                   -- enable PLL
+
+OSCCON_IRCF = 14 -- set 8 MHz (with PLL -> 32 MHz)
+
+enable_digital_io()
+
+-- setup the serial interface
+const serial_hw_baudrate = 115200           -- line speed
+alias serial_ctsinv  is pin_C5              -- incoming data flow control
+pin_C5_direction     =  OUTPUT
+var  bit serial_overflow_discard = false    -- no transmit buffer overflow
+include serial_hw_int_cts                   -- the library
+serial_hw_init()                            -- init the serial interface
+
+include print                               -- formatting routines
+
+var   byte str1[] = " PIC "
+print_string(serial_hw_data, str1)          -- sent 'PIC'
+print_string(serial_hw_data, PICTYPE)       -- sent PIC type after reset
+serial_hw_data = " "                        -- space
+
+var byte char
+forever loop
+   if (serial_hw_read(char) == true) then   -- char received
+      serial_hw_write(char)                 -- echo incoming char
+   end if
+end loop
+
=======================================
--- /dev/null
+++ /trunk/sample/16f1937_serial_hw_int_cts.jal Sun Feb  7 05:54:33 2010
@@ -0,0 +1,58 @@
+-- ------------------------------------------------------
+-- Title: Sample echo program for serial_hw_int_cts.jal for 16F1937
+--
+-- Author: Rob Hamerling, Copyright (c) 2008..2010, all rights reserved.
+--
+-- Adapted-by:
+--
+-- Compiler: 2.4n
+--
+-- This file is part of jallib  (http://jallib.googlecode.com)
+-- Released under the BSD license (http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description:
+-- Sample use of serial_hw_int_cts library for PIC16F1937
+-- Echoes all data received from the serial interface.
+-- Input flow control by CTS signalling makes sure buffer will not be overflowed
+-- (provided the sender has CTS output flow control enabled!)
+--
+-- Sources:
+--
+-- Notes: Uses resonator of crystal at 16 MHz (with PLL disabled)
+--
+-- ------------------------------------------------------
+
+include 16f1937
+
+pragma target   clock  16_000_000           -- osc frequency
+pragma target   OSC    hs                   -- 16 MHz resonator
+pragma target   WDT    disabled             -- no watchdog
+pragma target   PWRTE  enabled              -- powerup delay
+pragma target   LVP    disabled             -- no low voltage programming
+pragma target   DEBUG  disabled             -- no debug
+pragma target   PLLEN  P1                   -- disable PLL
+
+enable_digital_io()
+
+-- setup the serial interface
+const serial_hw_baudrate = 115200           -- line speed
+alias serial_ctsinv  is pin_C5              -- incoming data flow control
+pin_C5_direction     =  OUTPUT
+var  bit serial_overflow_discard = false    -- no transmit buffer overflow
+include serial_hw_int_cts                   -- the library
+serial_hw_init()                            -- init the serial interface
+
+include print                               -- formatting routines
+
+var   byte str1[] = " PIC "
+print_string(serial_hw_data, str1)          -- sent 'PIC'
+print_string(serial_hw_data, PICTYPE)       -- sent PIC type after reset
+serial_hw_data = " "                        -- space
+
+var byte char
+forever loop
+   if (serial_hw_read(char) == true) then   -- char received
+      serial_hw_write(char)                 -- echo incoming char
+   end if
+end loop
+
=======================================
--- /trunk/CHANGELOG    Sun Feb  7 01:06:46 2010
+++ /trunk/CHANGELOG    Sun Feb  7 05:54:33 2010
@@ -21,6 +21,7 @@
 samples:
  - added sample for writing and verifying 1024 bytes of eeprom with 18f6722
- Added blink-a-led samples for 16 extended midrange PICS (18/19[L]F18/19xx) + - Added 2 samples of serial comms with 16F1937 (different libraries and oscillators)

 compiler:
  -
=======================================
--- /trunk/TORELEASE    Sun Feb  7 01:06:46 2010
+++ /trunk/TORELEASE    Sun Feb  7 05:54:33 2010
@@ -352,6 +352,8 @@
 sample/16f1934_blink.jal
 sample/16f1936_blink.jal
 sample/16f1937_blink.jal
+sample/16f1937_serial_hardware.jal
+sample/16f1937_serial_hw_int_cts.jal
 sample/16f1938_blink.jal
 sample/16f1939_blink.jal
 sample/16f505_blink.jal

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