Abstract

The CC2650 is a wireless MCU with Bluetooth, ZigBee and 6LoWPAN capabilities. The micro-controller can be programmed in c/c++ and has libc and hardware interfaces implemented in the TI-RTOS kernel. The goal of this project is to enable quick, safe programming to the CC2650 without the usual learning curve of hardware programming, while supplying the hardware interfaces needed in order to implement a complex product. This was done by porting a JVM to the micro-controller and implementing the major hardware interfaces and base libraries in java. The final product of this project provides users with the ability to write embedded programs that interface with the UART, flash, buttons, and GPIO peripherals with the ease that comes with writing object-oriented java with garbage collection, threads and exceptions. By using the CC2650 LAUNCHXL which supplements the CC2650 with 1MB of SPI NOR flash, the code size available increases from 128K of native code to 1MB of java classes which can be deployed over UART without needing to reprogram the MCU program memory which contains the JVM.


Background


Motivation

Learning to program microcontrollers usually has a steep learning curve because of the need to learn memory management, power management and peripherals without the convenience of high level programming languages which supply garbage collection, object oriented programming, threads and exceptions. uJ helps bridge the gap by enabling us to run java on microcontrollers and implement embedded and IOT projects quickly and easily. This project brings these advantages to the CC2650 (and easily to all TI MCUs which are supported by TI-RTOS)


Challenges

As part of our goal to port uJ to the CC2650, the three major challenges in this project where compiling uJ to the CC2650, finding where to place the compiled java classes, and implementing java classes that interface with the launchpad peripherals.


Project Description

The uJ JVM was successfully compiled for the CC2650 with full support for all data types (double, float, long), exceptions, threading and synchronization. The jvm heap size available on the MCU is 12Kb and the jvm manages about 2500 java operations per second. The following java framework libraries were implemented partially:

and the following native interfaces were implemented:

Before running the jvm, java class files are placed one after the other in the SPI Flash of the LAUNCHXL, giving us almost 1Mb of memory for our code (in the case where there is no such flash, the code can be placed on any other read-only memory or as part of the program memory). The SPI Flash on the LAUNCHXL can only be programmed by code running on the MCU, creating the need for the flashprog project supplied in the source code. This project, which is compiled and flashed to the CC2650, receives data from the UART port and writes it to the SPI Flash, enabling us to write java classes over the UART port and then run them on the MCU. The final version of the jvm waits for commands over UART when started and can either run the existing class files, or receive java classes over UART, write them to the SPI Flash and then run them. All of this is managed by a python script which concatenates the java class files and sends them over UART to the MCU.


Example Application - Simon

The game of Simon was chosen in order to showcase the features, strength and ease of development that comes with running the jvm on our MCU. The game was developed and compiled entirely in the eclipse IDE for java and utilizes all the managed and native utilities described in the previous sections.

Gameplay

Initial Prompt

The game starts by flashing both the red and green LEDs and welcoming the player as well as showing the previous high score (which is saved in the SPI Flash). The game starts when one of the buttons is pressed.


Simon Says

The pattern to follow is displayed by the LEDs on the board and the player needs to repeat the same pattern by pressing the buttons. The level is raised every time the pattern is successfully repeated, which the board signals by turning on both LEDs. The pattern becomes longer and is displayed faster after every level.


Game Over

When the pattern is repeated incorrectly, the game ends (signalled by the red LED) and then starts from the beginning. If a new high score is achieved, it is saved in the SPI Flash.


Src

All sources and usage for this project can be found in the following git repo.


License

The original code and license can be found here.