Author: robhamerling
Date: Thu Feb 26 12:35:25 2009
New Revision: 814
Added:
trunk/include/peripheral/usb/usb_board.jal
Log:
Forgotten USB file (...may belong in test directory!).
Added: trunk/include/peripheral/usb/usb_board.jal
==============================================================================
--- (empty file)
+++ trunk/include/peripheral/usb/usb_board.jal Thu Feb 26 12:35:25 2009
@@ -0,0 +1,121 @@
+--
-----------------------------------------------------------------------------
+-- Title: USB PICDEM like board description
+-- Author: Albert Faber, 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 file is the setup for my homebrew, PICDEM like
18f4550 board
+-- The board consist of a reset button switch to gnd (tided to pin1, with
4k7 pull up)
+-- A program button switch to gnd (tided to pin37, with 4k7 pull up)
+-- A 20 MHz external crystal and 15pf caps connected to OSC1/2
+-- A 270nf cap connected to Vusb and gnd (pin 18)
+-- In addition, a MAX232 chip connccted to the USART pins, for serial
(mainly to debug)
+-- communication.
+-- The board is loaded with the standard microchip bootloader, therefore
the examples
+-- are compiled with the following JAL compiler flags: -loader18 -no-fuse
+--
+--
+--
+-- Sources: http://www.microchip.org for PICDEM docs
+--
+-- Notes: not sure about the compiler version
+--
+-- ------------------------------------------------------
+-- ------------------------------------------------------
+--
+--
+
+
+-- < Version: 1.1 24-02-2009, Albert Faber
+-- < 1.0 Orignal release
+-- < 1.1 Make RS-232 option configurable
+--
-----------------------------------------------------------------------------
+--
-----------------------------------------------------------------------------
+
+
+-- compiler dependant device definitions
+include 18f4550
+
+-- even though the external crystal is 20 MHz, the configuration is such
that
+-- the CPU clock is derived from the 96 Mhz PLL clock (div2), therefore set
+-- target frequency to 48 MHz
+pragma target clock 48_000_000
+
+-- whether or not using the serial port
+const HAS_SERIAL_DEBUG_PORT = 1
+
+-- include delay functions
+include delay
+
+-- disable comperators
+cmcon = 0x07
+
+if defined( HAS_SERIAL_DEBUG_PORT ) == true then
+
+ procedure init_usart() is
+ TRISC_TRISC7=1 -- RX
+ TRISC_TRISC6=0 -- TX
+ SPBRG = 0x67
+ SPBRGH = 0x00 -- 0x0271 for 48MHz -> 19200 baud, 0x0067
for 115200
+ TXSTA = 0x24 -- TX enable BRGH=1
+ RCSTA = 0x90 -- continuous RX
+ BAUDCON = 0x08 -- BRG16 = 1
+ end procedure
+
+ -- intialze serial device
+ init_usart()
+
+ procedure serial_putc( byte in ch ) is
+ while(!TXSTA_TRMT) loop
+ end loop
+ TXREG = ch
+ end procedure
+
+ -- not correct, but due to compiler issue, DIV functions are not working
+ -- for the 18f device(s), contacted Kyle about the issue, therefore
print
+ -- hex value for the time being
+ procedure serial_print_int( byte in value ) is
+ var byte nibble = value >>4
+ if ( nibble > 9 ) then
+ serial_putc( "A" - 10 + nibble )
+ else
+ serial_putc( "0" + nibble )
+ end if
+
+ nibble = value & 0x0F
+
+ if ( nibble > 9 ) then
+ serial_putc( "A" - 10 + nibble )
+ else
+ serial_putc( "0" + nibble )
+ end if
+ end procedure
+
+ procedure serial_print_int_hex( byte in value ) is
+ serial_print_int( value )
+ end procedure
+
+ -- only use for constant arrays, due to JAL compiler issue,
+ -- contacted Kyle about the issue
+ procedure serial_print_str( byte in str[]) is
+ var byte i
+ for count( str ) using i loop
+ serial_putc( str[ i ] )
+ end loop
+ end procedure
+
+ procedure serial_print_spc() is
+ serial_putc( " " )
+ end procedure
+
+ procedure serial_newline() is
+ serial_putc( 10 )
+ -- serial_putc( 13 )
+ end procedure
+
+end if
+
+
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---