CONTENTS

Home
Updates
Software
Electronics
Music
Resume
Contact


YouTube
Twitter
GitHub
LinkedIn


chipKIT PIC32 Java

Posted: January 1, 2016
Updated: May 1, 2016

Introduction

I've been working on adding MIPS32 (extended to Microchip's PIC32 microcontrollers) to Java Grinder so I can compile Java class files into native PIC32 programs. I had this chipKIT Uno32 laying around for a while (seems they don't make this board anymore) so I used this as my test board. Took some work figuring out how to program the board with Linux without using their IDE and to write a straight assembly language program for it. More below on how I got that working.

The API and MIPS32 generation is still a work in progress. More to come later.

The source code for the demo is in the Java Grinder repository.

Related Projects @mikekohn.net

Java Grinder: Playstation 2 Java, Nintendo 64 Java, Sega Genesis Java, Amiga Java, Apple IIgs Java, TI99/4A Java, C64 Java, dsPIC Mandelbrots, Atari 2600 Java, Intellivision Java, chipKIT Java, Java Grinder, naken_asm

Pictures

chipkit with LCD shield drawing a Mandelbrot

Above is a picture of a 4D Systems 4Display-Shield-22 LCD Display Shield. I think hardware-wise, this wasn't compatible with my ChipKit so it really doesn't work as well as it should. I might try getting another display later and trying again. Maybe even a newer ChipKit.

The source is here: Display.java

All of the LCD setup code was copied from the 4D Systems sample code.

Videos

Running the sample program LedBlink.java Full video: https://youtu.be/HL4SR5Z97_g

The source code to the demo LedBlink.java

Explanation

So the first step was to write a straight forward assembly language program, assemble it, and figure out how to upload it to the board. So I already had MIPS32 support in naken_asm, but I never tested it before. So I started by writing a set of automated tests to make sure the output of every instruction from naken_asm matches the output from pic32-as which was distributed with chipKIT's MPIDE. I then wrote a test program that would turn the 2 LED's on the board on or off: chipkit.asm

So when I did this I was a bit confused of what .org should be. According to the PIC32 documentation, the physical start of Program Flash is 0x1d000000. The start of the virtual memory for Program Flash is 0x9d000000. So which one was I supposed to use? Also I couldn't get avrdude to write my hexfile to the flash of the device. I ended up getting it to work with pic32prog. To figure out the correct .org to use, I compiled a small program in C and disassembled it with naken_util. Ends up the correct .org (I'm assuming due to way the chipKIT's bootloader works) is 0x1d001000.

Anyway, after getting my first straight assembly program running on the chipKIT, the next task was to get a small Java program to compile. I already had all the files set up for doing MIPS32. I extended it with a PIC32 class that sets the correct .org and ramstart variables and such for the PIC32. I had to add a bunch of code to the MIPS32.cxx file since it was pretty much empty.

Over this weekend (May 1, 2016) I added a simulator for MIPS32 in naken_asm so I can run the same automated testing in Java Grinder for MIPS that is run for MSP430. I think got Mandelbrots generating on an LCD like I did with the Java dsPIC Mandelbrots project.

Copyright 1997-2024 - Michael Kohn