Monthly Archive: February 2013

Compiling for pic18 using sdcc

Upgraded to sdcc 3.2.0 from 2.9.0, and gputils to 1.0.0. The build commands I was using didn’t work, chnages to the .c file and build commands were needed:

Changes to the .c file:

__code char __at(__CONFIG1H) __conf1h = _OSC_INTIO67_1H;
__code char __at(__CONFIG2H) __conf2h = _WDT_OFF_2H; //out for p18f4620
__code char __at(__CONFIG2L) __conf2l = _PWRT_OFF_2L & _BOREN_OFF_2L;
__code char __at(__CONFIG3H) __conf3h = _MCLRE_OFF_3H & _PBADEN_OFF_3H; //out for p18f4620
__code char __at(__CONFIG4L) __conf4l = _XINST_OFF_4L & _DEBUG_OFF_4L & _LVP_ON_4L;


#include "pic18f46k20.h"
//Instead of WDT=OFF, see the .inc file
//Instead of OSC, use FOSC, see the .inc file

The CONFIG settings in /usr/local/share/sdcc/non-free/include/pic16/pic18f46k20.h and /usr/local/share/gputils/header/ do not match. WDT changes to WDTEN, OSC to FOSC

Command to compile:

/usr/local/bin/sdcc -V -mpic16 --use-non-free -p18f46k20 -c p18_step_control.c -Wl"-s ./18f46k20.lkr"

Another App Idea

Have a game of electronic (or just electric) circuits. Give the player a few parts, as many wires as needed, and a goal. The player attaches the parts until the goal is achieved. The simplest case would be a battery and a light bulb, with the goal being to light the bulb.

Other basic components can be added, resistors, caps, diodes, LEDs, etc. The game would involve only simple circuits, to make it easier and to make modeling the results from the circuits the users make easier.

App game idea

Flip it

This game board is an array of tiles. The tiles have letters. The game play involves flipping a pair of letters, as if the two tiles can move through the screen on the axis that connects them. In any case, they move switches them. The goal is to rearrange the tiles to spell words.

cat --flip c:a--> act
dog ------------> dog

cat --flip c:d--> dat
dog ------------> cog

The game can be played different sized boards, and with boards with cutouts.
Variation 1: Have the tiles have both color and a letter, to distinguish common letters.
Variation 2: Have the tiles be two sided, so that flipping them exposes the other sides.

What is interesting about this is that it is a class of games easy to implement in the computer but which is hard or impossible to implement as a physical game. There is a whole class of variations on pen and pencil or board games that haven’t been tried because of this!