Happy newyear !


For the last couple of weeks, my fingers have been itching to work on a bunch of projects and keep a log about them. Then it occurred to me that I have a blog and that I managed to neglect it !
So let me fix that right now.

The past 6 months have been quite active.

From July through October, I was a member of the K.U.Leuven iGEM team creating the essencia coli bacterium that would create vanillin based on the amount of blue light received. The ingenious part of this bacterium was that it included a feedback loop to regulate the amount of vanillin in the environment.

In August I spent all of my time studying for 2 exams I had to take again: Systems theory and Thermodynamics. I passed both exams very well, but the exams rate as some of the worst experiences I've had taking exams.

At the end of october, beginning of november I went to MIT in Boston for the iGEM jamboree. Afterwards, most of the team went to New York. It was all great fun :) Pictures are on facebook

I started working on my thesis in september. It was first about lowlevel security in android smartphones, but the subject has now been altered to lowlevel attacks and defenses in general. Specifically, I'm doing research on data only attacks, but I'm not allowed to blog about it.

I'm now taking the master in engineering sciences: computerscience curriculum in 1 year, and the outlook is good. I plan to finish by june 2010. I've enrolled in the following courses:


  • Capita selecta: human-machine communication

  • French in the enterprise environment

  • Formal systems and applications

  • Athens course on "remotely controlled physics laboratories" at IST in Lisbon

  • Internet infrastructure

  • Multiagent systems



The first 2 courses run both semesters, the next 2 are in the 1st semester, the last 2 in the second semester.

The athens course from 14-21 november was very nice. More than the course, I appreciated the social interaction with my fellow students, all from foreign universities.

What else ?

I'm still active in the OverTheWire community. There was a breakin in one of the wargames servers and the cracker sniffed all network traffic. Because of this, the wargames server was taken down and is still not up. I am revising the current network topology and plan to have everything back up and running by the end of this week (fingers crossed)

I'm also planning to start working on a DIY CNC machine, but I don't know when those plans will become reality. Read full post

PIC16f627A with RS232 and sdcc


Programming PICs in assembly can be challenging, but it gets to be a drag after a while. Especially when doing serial communications you start wondering: "wouldn't it be great if all this fiddly crap was in some kind of library ?"

I've been playing with sdcc (Small Device C Compiler) to write code for the PIC. Unfortunately at the time I was playing with it (in the middle of exams), there was no library code to do RS232 for the 16f627a (at least not in a blatantly obvious way). So instead of asking for directions like any sane person would do, I dove right in and wrote it myself.

Now that I've upgraded to Ubuntu Jaunty (which is such a resource hog btw), I wonder if the sdcc people have included some code for the 16f627a but haven't checked.

In any case, I'll post the code here for all of you to laugh at and for me to have a backup for when my harddisk dies (any minute now)

lib.h:


#ifndef __LIB_H
#define __LIB_H

#define USART_TX_INT_ON 0xff
#define USART_TX_INT_OFF 0x7f

#define USART_RX_INT_ON 0xff
#define USART_RX_INT_OFF 0xbf

#define USART_BRGH_HIGH 0xff
#define USART_BRGH_LOW 0xef

#define USART_CONT_RX 0xff
#define USART_SINGLE_RX 0xf7

#define USART_SYNC_MASTER 0xff
#define USART_SYNC_SLAVE 0xfb

#define USART_NINE_BIT 0xff
#define USART_EIGHT_BIT 0xfd

#define USART_SYNCH_MODE 0xff
#define USART_ASYNCH_MODE 0xfe

void usart_open(unsigned char, unsigned int);

void usart_putc(unsigned char);
unsigned char usart_getc(void);

unsigned char usart_busy(void);
unsigned char usart_drdy(void);

unsigned char usart_wait_and_read(void);
void usart_wait_and_write(unsigned char);

#endif /* __LIB_H */


lib.c:

#include <pic/pic16f627a.h>
#include "lib.h"

void usart_open(unsigned char config, unsigned int spbrg) { /* {{{ */
TXSTA = 0; // Reset USART registers to POR state
RCSTA = 0;

if(config & ~USART_ASYNCH_MODE)
SYNC = 1;

if(config & ~USART_EIGHT_BIT) {
TX9 = 1;
RX9 = 1;
}

if(config & ~USART_SYNC_SLAVE)
CSRC = 1;

/*
if(config & ~USART_SINGLE_RX)
CREN = 1;
else
SREN = 1;
*/

CREN = 1;
SREN = 1;

if(config & ~USART_BRGH_LOW)
BRGH = 1;
else
BRGH = 0;

/* TX interrupts */
TXIF = 0;

if(config & ~USART_RX_INT_OFF)
RCIE = 1;
else
RCIE = 0;

/* RX interrupts */
RCIF = 0;

if(config & ~USART_TX_INT_OFF)
TXIE = 1;
else
TXIE = 0;

SPBRG = (char)spbrg;

TXEN = 1;
SPEN = 1;

TRISB1 = 1; // set B1 to transmit
TRISB2 = 0; // set B2 to receive
}
/* }}} */

void usart_putc(unsigned char dat) { /* {{{ */
//if(TX9) {
// TX9D = 0;
// if(USART_Status.TX_NINE)
// TX9D = 1;
//}

TXREG = dat; // Write the data byte to the USART
}
/* }}} */
unsigned char usart_getc(void) { /* {{{ */
return RCREG;
}
/* }}} */

unsigned char usart_busy(void) { /* {{{ */
return !TRMT;
}
/* }}} */
unsigned char usart_drdy(void) { /* {{{ */
return RCIF;
}
/* }}} */

unsigned char usart_wait_and_read(void) { /* {{{ */
while(!usart_drdy());
return usart_getc();
}
/* }}} */
void usart_wait_and_write(unsigned char dat) { /* {{{ */
while(usart_busy());
usart_putc(dat);
}
/* }}} */


test.c :

#include <pic/pic16f627a.h>
#include "lib.h"

#define GPSIM_20Mhz_2400baud_BRGHlow 0x81
#define GPSIM_20Mhz_9600baud_BRGHlow 0x20

#define PIC_4Mhz_2400baud_BRGHlow 0x19
#define PIC_4Mhz_9600baud_BRGHhigh 0x19

static __code unsigned short __at(0x2007) _conf = _INTRC_OSC_NOCLKOUT;

unsigned char data_num[] = {
0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f
};

unsigned char data_alpha[] = {
0x77, 0x7c, 0x58, 0x5e, 0x79, 0x71
};

//unsigned char hex[] = "0123456789ABCDEF"; <- this doesn't work yet
unsigned char hex[] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
};

void main()
{
unsigned char c = 'G';
usart_open(USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_BRGH_LOW & USART_EIGHT_BIT, GPSIM_20Mhz_2400baud_BRGHlow);

TRISA = 0;

for (;;)
{
c = usart_wait_and_read();

if(c >= 'A' && c <= 'F') {
PORTA = data_alpha[c - 'A'];
} else {
if(c >= '0' && c <= '9')
PORTA = data_num[c - '0'];
}

usart_wait_and_write(c);
usart_wait_and_write(':');
usart_wait_and_write(' ');
usart_wait_and_write('0');
usart_wait_and_write('x');
usart_wait_and_write(hex[(c & 0xf0) >> 4]);
usart_wait_and_write(hex[c & 0x0f]);
usart_wait_and_write('\n');
}
}


env.conf :

# load the gpsim modules library.
module lib /usr/lib/libgpsim_modules.so.0.0.0

# creating an usart and connecting its TX pin to the PICs RX pin, allowing keyboard input
module load usart U1
node nct
node ncr
attach nct pin(portb1) U1.TXPIN
attach ncr pin(portb2) U1.RXPIN
U1.console = true
U1.rxbaud = 2400
U1.txbaud = 2400

# creating a 7 segment led display and hooking it up to PORTA
module load led_7segments L7
node nl0 nl1 nl2 nl3 nl4 nl5 nl6
attach nl0 pin(porta0) L7.seg0
attach nl1 pin(porta1) L7.seg1
attach nl2 pin(porta2) L7.seg2
attach nl3 pin(porta3) L7.seg3
attach nl4 pin(porta4) L7.seg4
attach nl5 pin(porta5) L7.seg5
attach nl6 pin(porta6) L7.seg6

# tell the builtin scope in gpsim to monitor portb2
# (in gpsim: Windows -> Scope)
scope.ch0="portb1"


Makefile :

test.hex: test.o lib.o
gplink \
-c \
-s /usr/share/gputils/lkr/16f627a.lkr \
-o $@ \
-m \
$^ \
-I /usr/share/sdcc/lib/pic \
pic16f627a.lib libsdcc.lib

test.o: test.asm
gpasm -c $<

lib.o: lib.asm
gpasm -c $<

test.asm: test.c
sdcc -S -mpic14 -p16f627a $<

lib.asm: lib.c
sdcc -S -mpic14 -p16f627a $<

run:
gpsim -c env.conf -s test.cod

clean:
rm -f *.cod *.hex *.lst *~ *.o *.asm *.cof *.map

upload:
../K8048/k14 p test.hex
../K8048/k14 v test.hex


The code in test.c does RS232 in both directions. It takes a character and sends out the hex code for it. In addition, if the character is a hex digit (0123456789ABCDEF), it gets displayed on the 7 digit led display. Read full post

10% en in de regen !


My tracks
Time:00:24:48bpm (avg/max):168/177
Read full post

Nog wa lopen


In't donker door een bos lopen is toch altijd iets speciaals

My tracks
Time:00:24:14bpm (avg/max):165/177
Read full post

Breaking the Click Challenge v2.0 game on facebook


Breaking this game is a lot easier than Bejeweld Blitz. The score is sent with a GET request.


http://apps.facebook.com/click_challenge_vtwo/showscore.php?t=1&c=544325099909vf32345hfgfg5435f0486367&r=fd55507070&fdgdf=33459&htu=300045&vevr=34008725320&ggrt+sf&score=445gdfg2g2452456&gfhljkm3498&dgfgd=d0bsdd-sfg5-j334-562mxf32-s&s100&s=09&s=7988&c=vf35h&b=23&9454&grfd=45&fg=tyj&3g&dgfgd=20000&3vdhj=43005&oipedv=bsddsfg&bbf=g45j32mxf32


The field that needs changing is called dgfgd and is the score you want times 40. In this case, I wanted to set 500, so the field is set to 20000. The maximum seems to be 700 Read full post