Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Updates to manual programming
22-09-2013, 10:45 PM, (This post was last modified: 22-09-2013, 10:52 PM by dc_740.)
Updates to manual programming
Today while I was trying pinguino for the first time I started from scratch, trying to make it compile from sdcc without the ide. After a few changes I got a working Makefile, but I had one problem:
main.c imports user.c directly! giving you no other choice than placing your program inside source/user.c

I made a change to source/main.c file so I could leave my source files in a separate folder. I hope someone else will find it useful too and it can be included in Pinguino without affecting anything else

patch for source/main.c
Index: source/main.c
--- source/main.c    (revision 898)
+++ source/main.c    (working copy)
@@ -51,7 +51,12 @@
#include <io.c>     // needs define.h to be included first

+void setup();
+void loop();
#include "user.c"   // user's .pde file translated to C

#ifdef boot2

Here is a WORKING make file to compile with SDCC and no IDE:
(remember to change your pinguino install dir)
PINGUINOSDCCINCLUDES=-I$(PINGUINO)/p8/sdcc/include -I$(PINGUINO)/p8/sdcc/include/pic16 -I$(PINGUINO)/p8/sdcc/non-free/include/pic16 -I$(PINGUINO)/p8/pinguino/core -I$(PINGUINO)/p8/pinguino/libraries -I$(PINGUINO)/source
PINGUINOCONFIG=-DNO_PINGUINO_IDE -Dboot4 --obanksel=9 --optimize-cmp --optimize-df --denable-peeps --ivt-loc=3072 -D__SDCC_PIC18F4550 -DPIC18F4550 -DPINGUINO4550
PINGUINOLINKCONFIG=--no-crt libc18f.lib libm18f.lib -Wl-s$(PINGUINO)/p8/lkr/boot4.18f4550.lkr,-m
SDCCFLAGS= --use-non-free -mpic16 -p18f4550 -V -I./ $(PINGUINOSDCCINCLUDES) $(PINGUINOCONFIG)

%.o: %.c
    $(SDCC) $(SDCCFLAGS) -c $<

all: LedTest.o
    $(SDCC) $(SDCCFLAGS) -c -o main.o $(PINGUINO)/source/main.c
    $(SDCC) $(LINKFLAGS) -o LedTest.hex LedTest.o main.o

program: all
    pk2cmd -P -M -FLedTest.hex -JN

    rm *.o
    rm *.hex
    rm *.asm
    rm *.lst
    rm *.cod
    rm *.cof
    rm *.adb
    rm *.map

And here is my working test program:
// Program to control an LED using a switch
#include <pic18f4550.h>
#include <delay.h>

/* hardware definition for Pinguino 18f4550 board */
#define myLED 13    // RA0
#include <const.h>
#include <delay.c>
#include <digitalw.c>

// Configuration bits
#pragma config PLLDIV = 5, CPUDIV = OSC1_PLL2, USBDIV = 2
#pragma config FOSC = HSPLL_HS,FCMEN = OFF,IESO = OFF
#pragma config CCP2MX = ON, MCLRE=OFF, PBADEN = OFF, LPT1OSC = OFF
#pragma config STVREN = ON, XINST = OFF
#pragma config CP0 = OFF,CP1 = OFF,CP2 = OFF,CP3 = OFF,CPB = OFF,CPD = OFF
#pragma config WRT0 = OFF,WRT1 = OFF,WRT2 = OFF,WRT3 = OFF,WRTB = OFF,WRTC = OFF,WRTD = OFF
#pragma config EBTR0 = OFF,EBTR1 = OFF,EBTR2 = OFF,EBTR3 = OFF,EBTRB = OFF
#pragma config LVP = OFF,WDT = OFF,BOR = ON,PWRT = ON //thing to prevent auto reset

/* setup() is run once only */
void setup()
        pinmode(myLED, OUTPUT);

/* loop() loops forever */
void loop()
        Delayms(2000);   // delay 2 seconds between blinks
24-09-2013, 11:55 AM,
RE: Updates to manual programming
Is this example for Linux? If so, you could include it in the Wiki at which at the moment is only a placeholder begging to be populated.
24-09-2013, 02:15 PM,
RE: Updates to manual programming
Yes, this is a Linux example. I want to upload it to the wiki too, but I was waiting for a confirmation about the main.c patch file. I have to change the Makefile depending on the user.c location/name and I would really like to update the wiki with the posibility to have the source file in a different folder than the hardcoded "source/user.c"

Forum Jump:

Users browsing this thread: 1 Guest(s)