Mecrisp-stellaris Forth runs on Teensy 3.1

Status
Not open for further replies.

mschweiz

New member
For those of you interested in a native Forth for Teensy 3.1, there is a baremetal Forth called Mecrisp written by Matthias Koch under a GPL license.
I've configured a version to work on the Teensy 3.1.

The latest release (1.1.7) at this time has the mk20dx256 target that runs on the Teensy 3.1.
 
Looking in the tar file's contents using winzip, I see the K20 256 folder. In there is a .hex file. The name isn't Freescale or Teensy.
I suppose you'd use teensyduino's loader to get that hex file, independent of the Arduino tool chain/IDE, then push that down to a Teensy 3.1.
I'd guess then that you'd open a serial monitor to interact with the Forth interpreter.
The archive file has a document on the Forth interpreter's user interface and the words that are implemented. Looks like serial ports can be used, maybe a timer. Not much else yet.
 
The folder "mk20dx256" contains a file named " mecrisp-stellaris-mk20dx256.hex". Use the Teensy Loader application to download via USB to the Teensy 3.1.

To connect to the Forth interpreter, use serial port 1 (not USB, serial). This is Pins 0&1 as shown on the pinout page. Set terminal software (minicom, screen, picoterm, etc) to 115,200 bps, 8,N,1. You may need to have it automatically add a LF after the CR to get the display correctly.

There are hooks for interrupts (adc0/1, cmp0-2, dac, porta-e, and systick). There is a "dissassembler" in the common code directory, and code for setting the system lock and demonstrating how to turn on/off the led in the "mk20dx256" directory. It's a very basic kernel at the moment ... but fully functional. With your help, I'm sure we could build quite a useful Forth vocabulary.

I'm new to both the Teensy/ARM Cortex-m4 as well as Forth, but will help to the extent I can.
 
The folder "mk20dx256" contains a file named " mecrisp-stellaris-mk20dx256.hex". Use the Teensy Loader application to download via USB to the Teensy 3.1.

To connect to the Forth interpreter, use serial port 1 (not USB, serial). This is Pins 0&1 as shown on the pinout page. Set terminal software (minicom, screen, picoterm, etc) to 115,200 bps, 8,N,1. You may need to have it automatically add a LF after the CR to get the display correctly.

There are hooks for interrupts (adc0/1, cmp0-2, dac, porta-e, and systick). There is a "dissassembler" in the common code directory, and code for setting the system lock and demonstrating how to turn on/off the led in the "mk20dx256" directory. It's a very basic kernel at the moment ... but fully functional. With your help, I'm sure we could build quite a useful Forth vocabulary.

I'm new to both the Teensy/ARM Cortex-m4 as well as Forth, but will help to the extent I can.
Neat!
The Stellaris name caused me moments of confusion with T.I. vs. Freescale!
 
Hello mschweiz, I have been working with your Teensy 3.1 Forth port quite a bit lately.

https://github.com/AndreasBWagner/mecrisp-stellaris

I have:

- Added Digital-to-Analog (DAC) support.
- DAC sine-wave, square-wave and triangle-wave examples. They look good when using my bus pirate as an oscilloscope.
- Changed Forth source file extensions from .txt to .4th to reflect the contents (I hope nobody minds).
- Reorganized some directories and switched to a common Makefile for all boards.
- Added a modified am4up (me4up) for rapidly uploading source files.

Now, I am working on:
- Getting the DAC to work with DMA ( Using https://github.com/lukvog/HUGO/blob/master/libraries/Audio_master/output_dac.cpp and the datasheet as references).
- Adding Analog-to-Digital (ADC) support (also with the option of using DMA).

For DMA I replaced:

Code:
.word nullhandler+1  @ DMA Channel 5 Transfer Complete and Error

with:

Code:
.word irq_vektor_dma_ch5+1  @ DMA Channel 5 Transfer Complete and Error


and:

Code:
.word nullhandler+1 @ 72 PDB

with:

Code:
.word irq_vektor_pdb+1 @ 72 PDB

In vectors.s

And added:

Code:
interrupt dma_ch4
interrupt pdb

to interrupts.s

I also needed to change to:

Code:
MEMORY
{
   rom(RX)   : ORIGIN = 0x00000000, LENGTH = 256K   /* 0x40000 */
   ram(WAIL) : ORIGIN = 0x1FFF8000, LENGTH = 64K    /* */
}

In the linker file to get the thing to build with more interrupts.

When I installed the resulting .hex file and rebooted the Teensy 3.1, I got an endless loop of "Unhandled Interrupt !"

I found that I can have either interrupt (pdb or dma_ch4), but not both. This would indicate that maybe the size of a segment is too small (?)

For now I have commented out the lines that for "Unhandled Interrupt !" in vectors.s and commented out ", unhandled" in interrupts.s

Code:
@unhandled:
@  push {lr} 
@  writeln "Unhandled Interrupt !"
@  pop {pc}

This allows me to get to the prompt again, but it's not a solution -- I would still like to know if I have an unhandled interrupt.

Maybe you know more than me about why this isn't working. I would very much appreciate any ideas for solving this problem.

Thanks,

Andreas
 
Status
Not open for further replies.
Back
Top