
;------------------------------------------------------------------------------
; Mecrisp 0.9 Addon 1: Time to conquer your Launchpad !
;------------------------------------------------------------------------------

Included in this package:

-Common and useful Forth basis definitions for MSP430G2553 in Launchpad
-Hex file of vanilla forth-mecrisp-2553 with those definitions already loaded
-Tidied up disassembler
-Experimental Mecrisp for MSP430F1612 with initialisations for Launchpad hardware
-TUSB3410 firmware file, just in case.

;------------------------------------------------------------------------------
; Common and useful Forth basis definitions for MSP430G2553 in Launchpad
;------------------------------------------------------------------------------

-Port definitions
-Hardware initialisations
-PWM on green led
-Random numbers
-Temperature and Vcc measurement
-Simple busy wait routines
-Cornerstone to delete parts of flash and an hexdump tool

Put the output of hexdump at the beginning of the vanilla 0.9 forth-mecrisp-2553.hex file 
to generate a new hex file that includes your dictionary contents and can be used to clone
finished forth projects !

Try:

: ?button   ( -- Flag ) 8 p1in cbit@ not ;
: led-red   ( Flag -- ) if  1 p1out cbis! else  1 p1out cbic! then ;
: led-green ( Flag -- ) if 64 p1out cbis! else 64 p1out cbic! then ;

?button led-red

1024 pwm-init
1 pwm
10 pwm
200 pwm
500 pwm
1000 pwm 

For terminal communication in Linux, picocom ist just nice.
http://code.google.com/p/picocom/

Invocation:

#!/bin/bash

lsusb
stty 9600 raw -F /dev/ttyACM0
./picocom /dev/ttyACM0 --imap lfcrlf,crcrlf --omap delbs,crlf --send-cmd "ascii-xfr -s -l 250 -n"

Type Ctrl-A and Ctrl-X to exit Picocom, Ctrl-A and Ctrl-S to load Forth source files.

Strangely, you can only connect terminal or use mspdebug once. 
Then you have to unplug and replug the Launchpad. 
This is a known bug for Launchpad firmware...

;------------------------------------------------------------------------------
; Experimental Mecrisp for MSP430F1612 with initialisations for Launchpad hardware
;------------------------------------------------------------------------------

If you have a 4 wire JTAG adapter and a spare (or bricked) launchpad, this is your item !

Don't forget to read and save a copy of the original launchpad 1612 firmware
first if you want to go back !!

JTAG signals of MSP430F1612 are accessible as nicely spaced test pins.

TP2: Reset
TP4: TCK
TP5: TMS
TP6: TDI
TP7: TDO 

Mecrisp for F1612 has special hardware initialisations to activate the TUSB3410 without
the USB-Firmware in I2C-EEprom. This way, the TUSB3410 boots over USB and gets
a standard firmware image from PC which configures it as a simple serial bridge.
Set the serial interface to 9600 baud, 8N1 - and feel free to write your own
open firmware for the Launchpad.

Unfortunately, only a few pins are accessible... 

P5.3 is on TEST jumper
P5.1, P5.2, P4.6, P2.4 seem to be all together on RESET jumper
P3.6 and P3.7 are on the TXD and RXD jumpers.

Others are occupied by launchpad hardware:

P5.5 supplies SMCLK as clock for the TUSB3410
P4.6 Reset line of TUSB3410
P3.1 SDA and P3.3 SCL are both tied low to deactivate I2C boot of TUSB3410
P3.4 and P3.5 are USART0 pins that communicate with the host.

Good luck ! As there are no accessible analog pins, no analog support is included.

Forth SBW and 4-wire JTAG routines are in progress.

Terminal is almost the same - just change the above to /dev/ttyUSB0.
Copy ti_3410.fw to /lib/firmware if needed.

With this configuration, you can reconnect without issues.
