PIC

From the Linux and Unix Users Group at Virginia Teck Wiki
Revision as of 14:51, 5 February 2011 by imported>Cov (Created page with "'''PIC''' microcontrollers are a RISC line from Microchip. They are used in ECE 2504 Introduction to Computer Engineering and [[ECE 45...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

PIC microcontrollers are a RISC line from Microchip. They are used in ECE 2504 Introduction to Computer Engineering and ECE 4534 Embedded System Design].

Compiling Code

MPLAB is IDE recommended by the ECE department. It can be run inside a Virtual Machine, programming using USB passthrough. It can also be installed under wine and the compiler used from the commandline. sdcc is reported to work, and pikdev has a C compiler for the PIC as well.

Makefile Using Wine

PRG = dspic_oscope
OBJS = main.o uart-multiplex.o adc.o spi.o spi_drivers.o readline.o

CC = wine pic30-gcc
BIN2HEX = wine pic30-bin2hex

MCU=33FJ128GP802
C30LIB="C:\Program Files\Microchip\MPLAB C30\lib"
CFLAGS = -mcpu=$(MCU) -x c -Wall -Os -std=gnu99
LDFLAGS = -mcpu=$(MCU) -Wl,-L$(C30LIB),-Tp$(MCU).gld,--defsym=__MPLAB_BUILD=1,-Map="$(PRG).map"
#,--report-mem
#LIBS = -ldsp-coff
LIBS =

all: $(PRG).hex

flash: all
    pk2cmd -F$(PRG).hex -M -PF6 -W -R

clean:
    rm -f $(OBJS) $(PRG).cof $(PRG).hex $(PRG).map

%.hex: %.cof
    $(BIN2HEX) $<

$(PRG).cof: $(OBJS)
    $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)

.c.o:
    $(CC) $(CFLAGS) -c $<

See Also

External Links