Open main menu

Linux and Unix Users Group at Virginia Teck Wiki β

Changes

PIC

3,323 bytes added, 21:21, 9 February 2011
no edit summary
'''PIC''' microcontrollers are a [[w:Reduced_instruction_set_computing|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.
===Using Wine to Run the Toolchain===The MCC18 toolchain can be run using wine. This page should be updated to give more detailed instructions. ===Makefile Using Wine===The file below is a work in progress.
<pre>
PRG # Hacked up makefile for Linux export WINEPREFIX = /home/user/class/embedded/pic/toolchainMCCPATH = $(WINEPREFIX)/drive_c/MCC18/binCC = wine $(MCCPATH)/mcc18.exeCFLAGS = --extended -Opa-# -D__DEBUG -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-LD = wine $(MCCPATH)/mplink.exeAR = wine $(MCCPATH)/mplib.exePK2PATH = dspic_oscope/home/user/class/embedded/pic/pk2cmd/pk2cmdv1.20LinuxMacSourceOBJS PK2CMD = $(PK2PATH)/pk2cmdRM = rm Proj1.cof : main.o uart-multiplexmessages.o interrupts.o user_interrupts.o my_uart.o uart_thread.o timer1_thread.o timer0_thread.o my_i2c.o $(LD) /p18F2680 /l"C:\MCC18\lib" "main.o" "messages.o" "interrupts.o" "user_interrupts.o" "my_uart.o" "uart_thread.o adc" "timer1_thread.o spi" "timer0_thread.o spi_drivers" "my_i2c.o readline" /u_CRUNTIME /u_EXTENDEDMODE /z__MPLAB_BUILD=1 /m"Proj1.map" /w /o"Proj1.cof"
main.o : main.c ../toolchain/drive_c/MCC18/h/stdio.h ../toolchain/drive_c/MCC18/h/usart.h ../toolchain/drive_c/MCC18/h/i2c.h ../toolchain/drive_c/MCC18/h/timers.h messages.h my_uart.h my_i2c.h uart_thread.h timer1_thread.h timer0_thread.h main.c maindefs.h ../toolchain/drive_c/MCC18/h/p18f2680.h ../toolchain/drive_c/MCC18/h/stdarg.h ../toolchain/drive_c/MCC18/h/stddef.h ../toolchain/drive_c/MCC18/h/pconfig.h interrupts.h $(CC ) -p= wine pic3018F2680 "main.c" -gccBIN2HEX fo= wine pic30-bin2hex"main.o" $(CFLAGS)
MCU=33FJ128GP802C30LIB="Cmessages.o :\Program Files\Microchip\MPLAB C30\lib"messages.c messages.h messages.c maindefs.h ../toolchain/drive_c/MCC18/h/p18f2680.h interrupts.hCFLAGS = -mcpu= $(MCUCC) -x p=18F2680 "messages.c " -Wall -Os -stdfo=gnu99LDFLAGS = -mcpu=$(MCU) -Wl,-L$(C30LIB),-Tp$(MCU)"messages.gld,--defsym=__MPLAB_BUILD=1,-Map=o"$(PRGCFLAGS).map"#,--report-mem#LIBS = -ldsp-coffLIBS =
allinterrupts.o : interrupts.c messages.h my_uart.h interrupts.c maindefs.h ../toolchain/drive_c/MCC18/h/p18f2680.h interrupts.h user_interrupts.h $(PRGCC)-p=18F2680 "interrupts.hexc" -fo="interrupts.o" $(CFLAGS)
flashuser_interrupts.o : alluser_interrupts.c ../toolchain/drive_c/MCC18/h/timers.h messages.h my_uart.h user_interrupts.c maindefs.h ../toolchain/drive_c/MCC18/h/p18f2680.h ../toolchain/drive_c/MCC18/h/pconfig.h user_interrupts.h pk2cmd -F $(PRGCC)-p=18F2680 "user_interrupts.hex c" -M -PF6 -W -Rfo="user_interrupts.o" $(CFLAGS)
cleanmy_uart.o :my_uart.c ../toolchain/drive_c/MCC18/h/usart.h messages.h my_uart.h my_uart.c maindefs.h ../toolchain/drive_c/MCC18/h/p18f2680.h ../toolchain/drive_c/MCC18/h/pconfig.h rm -f $(OBJS) $(PRGCC)-p=18F2680 "my_uart.cof $(PRG)c" -fo="my_uart.hex o" $(PRGCFLAGS).map
%uart_thread.hexo : %uart_thread.cofc ../toolchain/drive_c/MCC18/h/stdio.h uart_thread.h uart_thread.c maindefs.h ../toolchain/drive_c/MCC18/h/p18f2680.h ../toolchain/drive_c/MCC18/h/stdarg.h ../toolchain/drive_c/MCC18/h/stddef.h $(BIN2HEXCC) -p=18F2680 "uart_thread.c" -fo="uart_thread.o" $<(CFLAGS)
$(PRG)timer1_thread.cofo : $(OBJS)timer1_thread.c ../toolchain/drive_c/MCC18/h/stdio.h messages.h timer1_thread.h timer1_thread.c maindefs.h ../toolchain/drive_c/MCC18/h/p18f2680.h ../toolchain/drive_c/MCC18/h/stdarg.h ../toolchain/drive_c/MCC18/h/stddef.h $(CC) $(LDFLAGS) -p=18F2680 "timer1_thread.c" -fo="timer1_thread.o $@ $^ " $(LIBSCFLAGS)
timer0_thread.o : timer0_thread.c ../toolchain/drive_c/MCC18/h/stdio.h timer0_thread.h timer0_thread.cmaindefs.h ../toolchain/drive_c/MCC18/h/p18f2680.h ../toolchain/drive_c/MCC18/h/stdarg.h ../toolchain/drive_c/MCC18/h/stddef.h $(CC) -p=18F2680 "timer0_thread.c" -fo="timer0_thread.o" $(CFLAGS) my_i2c.o:my_i2c.c ../toolchain/drive_c/MCC18/h/i2c.h messages.h my_i2c.h my_i2c.c maindefs.h ../toolchain/drive_c/MCC18/h/p18f2680.h ../toolchain/drive_c/MCC18/h/pconfig.h $(CC) -p=18F2680 "my_i2c.c" -fo="my_i2c.o" $(CFLAGS)  clean : $(RM) "main.o" "messages.o" "interrupts.o" "user_interrupts.o" "my_uart.o" "uart_thread.o" "timer1_thread.o" "timer0_thread.o" "my_i2c.o" "Proj1.cof" "Proj1.hex" "Proj1.map" prog : Proj1.hex $(PK2CMD) -A3.3 -c B$<(PK2PATH) -P -M -FProj1.hex -Y -T
</pre>
==See AlsoProgramming==* See the [[PICKit 2]]article for programming your hex file natively using <code>pk2cmd</code>. ==Debugging==Reading printf-style debugging messages over UART with the PICKit 2 is possible from a Windows virtual machine with USB passthrough.
==External Links==
* [[http://hackaday.com/2010/11/03/how-to-program-pics-using-linux/ How-to Program PICs using Linux - Hackaday]] (see article and comments)
Anonymous user