<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TK</title>
	<atom:link href="http://blog.rasterburn.org/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.rasterburn.org</link>
	<description></description>
	<lastBuildDate>Mon, 18 Jun 2012 21:22:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>World&#8217;s oldest photography</title>
		<link>http://blog.rasterburn.org/?p=176</link>
		<comments>http://blog.rasterburn.org/?p=176#comments</comments>
		<pubDate>Mon, 18 Jun 2012 21:14:05 +0000</pubDate>
		<dc:creator>TK</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.rasterburn.org/?p=176</guid>
		<description><![CDATA[I found a little gem; The world's oldest photography, taken by Nicéphore Niépce 186 years ago, in 1826. Notice the light being cast from both sides, so you can see the buildings being lit from the left and from the right. This is due to the 8-hour exposure of this photo. Nicéphore was clearly a [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/View_from_the_Window_at_Le_Gras%2C_Joseph_Nic%C3%A9phore_Ni%C3%A9pce.jpg/640px-View_from_the_Window_at_Le_Gras%2C_Joseph_Nic%C3%A9phore_Ni%C3%A9pce.jpg" alt="World's first photography (1826)" /></p>
<p>I found a little gem; The world's oldest photography, taken by Nicéphore Niépce 186 years ago, in 1826.</p>
<p>Notice the light being cast from both sides, so you can see the buildings being lit from the left and from the right. This is due to the 8-hour exposure of this photo.</p>
<p>Nicéphore was clearly a clever guy. His other inventions included the Pyréolophore, which is probably the first internal combustion engine, invented 1807. That year it powered a boat upstream on the river Saone.</p>
<p>Sources: <a href="http://en.wikipedia.org/wiki/Nic%C3%A9phore_Ni%C3%A9pce" title="Nicéphore (wikipedia)" target="_blank">Nicéphore (wikipedia)</a> and <a href="http://en.wikipedia.org/wiki/Pyr%C3%A9olophore" title="Pyréolophore (wikipedia)" target="_blank">Pyréolophore (wikipedia)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rasterburn.org/?feed=rss2&#038;p=176</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing 500px</title>
		<link>http://blog.rasterburn.org/?p=170</link>
		<comments>http://blog.rasterburn.org/?p=170#comments</comments>
		<pubDate>Wed, 04 Jan 2012 15:22:55 +0000</pubDate>
		<dc:creator>TK</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.rasterburn.org/?p=170</guid>
		<description><![CDATA[To the photographers out there... I've been active on 500px.com lately. It's a really cool photo sharing site where people aim to upload their very best photos. Most galleries are small, which makes it more fun to browse through them. Take a look at it, and check out my portfolio here: http://500px.com/torbjorn (link opens in [...]]]></description>
			<content:encoded><![CDATA[<p>To the photographers out there...</p>
<p><a href="http://imgur.com/8lRin"><img src="http://i.imgur.com/8lRin.jpg" alt="" title="Hosted by imgur.com" /></a></p>
<p>I've been active on 500px.com lately. It's a really cool photo sharing site where people aim to upload their very best photos. Most galleries are small, which makes it more fun to browse through them. </p>
<p>Take a look at it, and check out my portfolio here: <a href="http://500px.com/torbjorn" title="http://500px.com/torbjorn" target="_blank">http://500px.com/torbjorn<br />
</a> (link opens in a new tab).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rasterburn.org/?feed=rss2&#038;p=170</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSP430 and the GNU Debugger (GDB)</title>
		<link>http://blog.rasterburn.org/?p=136</link>
		<comments>http://blog.rasterburn.org/?p=136#comments</comments>
		<pubDate>Sun, 19 Jun 2011 20:53:34 +0000</pubDate>
		<dc:creator>TK</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.rasterburn.org/?p=136</guid>
		<description><![CDATA[Here's a short how-to on how to use the GNU Debugger (GDB) alongside the MSP430 development tools on OS X (Note that these steps will also work on Un*x). Up until now I've been using mspdebug for everything, and I think it's time to wield the power of gdb. Start mspdebug like this: $ mspdebug [...]]]></description>
			<content:encoded><![CDATA[<p>Here's a short <strong>how-to</strong> on how to use the GNU Debugger (GDB) alongside the MSP430 development tools on OS X (Note that these steps will also work on Un*x).</p>
<p>Up until now I've been using mspdebug for everything, and I think it's time to wield the power of gdb.</p>
<p>Start mspdebug like this:</p>
<div style="background-color: black; color: #c0c0c0;">
<pre><code>$ mspdebug rf2500 gdb</code></pre>
</div>
<p>In another window, start GDB and connect to mspdebug on port 2000.</p>
<div style="background-color: black; color: #c0c0c0;"><code><br />
$ msp430-gdb<br />
GNU gdb (GDB) 7.0.1<br />
Copyright (C) 2009 Free Software Foundation, Inc.<br />
License GPLv3+: GNU GPL version 3 or later<br />
This is free software: you are free to change and redistribute it.<br />
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"<br />
and "show warranty" for details.<br />
(gdb) <span style="color: #ffff00;">target remote localhost:2000</span><br />
[...]<br />
(gdb) <span style="color: #ffff00;">file test.elf</span><br />
[...]<br />
(gdb) <span style="color: #ffff00;">load test.elf</span><br />
Loading section .text, size 0x4e lma 0xf800<br />
Loading section .vectors, size 0x20 lma 0xffe0<br />
Start address 0xf800, load size 110<br />
Transfer rate: 728 bytes/sec, 55 bytes/write. </code><code>(gdb)<br />
</code></p>
</div>
<p>Here are some commands of interest:</p>
<ul>
<li>info registers</li>
<li>info breakpoints</li>
<li>break &lt;function-name&gt;</li>
<li>continue / cont</li>
<li>q  (quit)</li>
</ul>
<p>Full GDB manual here: <a href="http://sourceware.org/gdb/current/onlinedocs/gdb/">http://sourceware.org/gdb/current/onlinedocs/gdb/</a></p>
<p>Examples will follow in later articles, but for now we've simply shown the few steps required to get started with GDB. Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rasterburn.org/?feed=rss2&#038;p=136</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quicktip: UTF-8 in irssi within GNU screen</title>
		<link>http://blog.rasterburn.org/?p=130</link>
		<comments>http://blog.rasterburn.org/?p=130#comments</comments>
		<pubDate>Mon, 06 Jun 2011 18:50:11 +0000</pubDate>
		<dc:creator>TK</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.rasterburn.org/?p=130</guid>
		<description><![CDATA[Here's a small tip to get UTF-8 to work properly in irssi running within GNU screen: Add the following to ~/.screenrc defutf8 on Then start screen with the -U parameter, and start irssi. /set term_charset utf-8 /set recode_autodetect_utf8 ON /save Also add the following to your ~/.bashrc, but it may not be required: export LANG=en_US.UTF-8 [...]]]></description>
			<content:encoded><![CDATA[<p>Here's a small tip to get UTF-8 to work properly in irssi running within GNU screen:</p>
<p>Add the following to ~/.screenrc</p>
<div style="background-color: black; color: #c0c0c0;"><code></p>
<pre>defutf8 on</pre>
<p></code></p>
</div>
<p>Then start screen with the -U parameter, and start irssi.</p>
<div style="background-color: black; color: #c0c0c0;"><code></p>
<pre>/set <span style="color: #ff6600;">term_charset</span> utf-8
/set <span style="color: #ff6600;">recode_autodetect_utf8</span> ON
/save</pre>
<p></code></div>
<p>Also add the following to your ~/.bashrc, but it may not be required:</p>
<div style="background-color: black; color: #c0c0c0;"><code></p>
<pre>
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
</pre>
<p></code></div>
<p>UTF-8 encoding now works, it's as simple as that. (Note for reference, I've only tested this within Terminal.app on OS X).  Next time you re-attach to this screen, remember to do so with the -UrD parameter.</p>
<p>TedSki on #motorcycles (EFNet IRC) came up with this solution and told me about it.  Here's after the first test:</p>
<div style="background-color: black; color: #c0c0c0;">
<pre><code>
[20:37] &lt; <span style="color: #ff6600;">sgtzx</span>&gt; let's give it another shot
[20:37] &lt; <span style="color: #ffff00;">TedSki</span>&gt; sgtzx: 華語
[20:37] &lt; <span style="color: #ff6600;">sgtzx</span>&gt; yes, works!
[20:37] &lt; <span style="color: #ffff00;">TedSki</span>&gt; there ya go
</code></pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.rasterburn.org/?feed=rss2&#038;p=130</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with a chip from Texas Instruments [part 2]</title>
		<link>http://blog.rasterburn.org/?p=97</link>
		<comments>http://blog.rasterburn.org/?p=97#comments</comments>
		<pubDate>Sun, 05 Jun 2011 07:53:40 +0000</pubDate>
		<dc:creator>TK</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.rasterburn.org/?p=97</guid>
		<description><![CDATA[Last time we simply switched on two LEDs and let them shine forever (well, until someone pulled the power!).  I feel it's almost too trivial of an example, but on the other hand; getting past the initial challenges of using the GNU assembler/linker and explaining the basic concepts is essential. Let's take it one tiny [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.rasterburn.org/?p=80">Last time</a> we simply switched on two LEDs and let them shine forever (well, until someone pulled the power!).  I feel it's almost too trivial of an example, but on the other hand; getting past the initial challenges of using the GNU assembler/linker and explaining the basic concepts is essential.</p>
<p>Let's take it one <strong>tiny</strong> step further.  Let's light up those two LEDs one after the other, like a siren light.</p>
<p>To accomplish this, we'll be exploring interrupts and timers.  The MSP chip has a Basic Clock Module that helps us to write embedded applications with extremely low power consumption.  We'll be using the DCO (digitally controlled oscillator) clock source. Now, three clock signals are available from the Basic Clock Module, namely ACLK, MCLK and SMCLK. We'll be using the SMCLK; the sub-main clock!</p>
<p>The clockrate at which we will be sourcing the SMCLK from DCO is approx. 1MHz. Not exactly mind-boggingly fast, but keep in mind that MSP is a very power efficient microcontroller.</p>
<p><strong>Note</strong> that if you wanted to use the MSP for something that requires good timing, then you'd add a crystal to the circuit.  I don't have a crystal, but I see that the LaunchPad development kit supports soldering a crystal oscillator onto it (e.g. a 32 768 kHz watch crystal).</p>
<p>In configuring the Basic Clock Module, I just went for the default settings as specified in the MSP430 user manual, as seen below:</p>
<div style="background-color: black; color: #c0c0c0;">
<p><code></p>
<pre>    clr.b   &amp;DCOCTL                             ; set lowest DCOx and MODx settings
    bis.b   #DCO2+DCO1+DCO0, &amp;DCOCTL            ; select max DCO Tap
    bis.b   #RSEL0+RSEL1+RSEL2, &amp;BCSCTL1        ; select range 7</pre>
<p></code>
</div>
<p>We'll be using Timer A which is an integral part of all the MSP chips.  Some MSP-chips also have Timer B onboard, but I haven't played with that yet.  For this simple and rather unsophisticated example, we'll just set a "highish" TACCR0 value. Doing so we achieve a slight delay between changing the LEDs lights.  You'll see that I used 0xFFFF in the source code.</p>
<p>Let's source Timer A from SMCLK.  We're going to be using TACTL, the control register for Timer A. It has a structure specified in the manuals, and as you can see we set it to 0x0210. Translated to binary that is <strong>0000 0010 0001 0000</strong>.  If you compare this to the structure of this control register, you'll see that we'll be sourcing from SMCLK (and not ACLK etc), and MC "Up-Mode". Up-mode simply means that we let the timer count up to the value in TACCR0, and then it resets back to zero.</p>
<p>We still need to trigger an interrupt so we can alternate the lights!  For this we'll be setting TACCTL1, which is the capture/compare control register for Timer A.  As you can see from the source code below, I'm setting it to 0x0F0.  That's <strong>0000 0000 0000 1111</strong> in binary. Have a look at the MSP430 specs, and you'll see that we're setting the CCIFG, COV, OUT and CCI flags. From this setting, we'll make sure that our interrupt is raised when the timer has counted up to the value in TACCR0.</p>
<p>Check the interrupt vector table below and note that I've inserted "siren" as the entry for the Timer A interrupt.  This means that for each time the counter reaches TACCR0, we'll be executing the code from the "siren" label.</p>
<p>Let's get to the source. Take the test.asm file from the previous example, clear it and paste the following:</p>
<div style="background-color: black; color: #c0c0c0;">
<p><code></p>
<pre>.global <span style="color: #ff6600;">main</span>

; Constants/registers
.set    WDTCTL,     0x0120          ; watchdog control port
.set    WDTPW,      0x5A00          ; watchdog power
.set    WDTHOLD,    0x0080          ; watchdog hold
.set    P1DIR,      0x0022          ; direction of data bits on port P1
.set    P1SEL,      0x026
.set    P1OUT,      0x021
.set    TACCR1,     0x0174
.set    TACCR0,     0x0172
.set    TACTL,      0x0160          ; Timer A is 0x0160 to 0x017F
.set    TACCTL1,    0x0164          ; Capture/compare control register
.set    DCOCTL,     0x056           ; DCO control register
.set    BCSCTL1,    0x058           ; Oscillator control register #2

; Settings for Basic Clock Module
.set    RSEL0,      0x01            ; These bits select the frequency
.set    RSEL1,      0x02            ; range of the DCO
.set    RSEL2,      0x04
.set    DCO0,       0x20            ; These bits set the fundamental frequency
.set    DCO1,       0x40            ; of the DCO, within the range defined by the
.set    DCO2,       0x80            ; RSEL bits above.

.text
<span style="color: #ff6600;">main</span>:
    dint
    mov     #0x0280, r1             ; set stackpointer to top of RAM
    mov     #WDTPW+WDTHOLD, &amp;WDTCTL ; stop watchdog

    ; let's configure the basic clock module
    clr.b   &amp;DCOCTL                             ; set lowest DCOx and MODx settings
    bis.b   #DCO2+DCO1+DCO0, &amp;DCOCTL            ; select max DCO Tap
    bis.b   #RSEL0+RSEL1+RSEL2, &amp;BCSCTL1        ; select range 7

    ; we set red LED, keeping green LED cleared for now
    bis.b   #0x01, &amp;P1DIR
    bic.b   #0x40, &amp;P1DIR

    ; set P1.0 = TA0.1 (OUT1 is timer A's output)
    bis.b   #0x01, &amp;P1SEL

    ; we need to set CCR0,
    ; in our case to the highest possible value (all bits set in 16-bit value)
    mov     #0xFFFF, &amp;TACCR0

    ; we need to source timer A from SMCLK, up mode. We counts up to the value in CCR0,
    ; and then it resets to zero.
    mov     #0x0210, &amp;TACTL

    ; Interrupt when timer has counted up to the value in CCR0 (see above)
    mov     #0x0f0, &amp;TACCTL1

    ; enable interrupts and shut down cpu (LPM0 with interrupts enabled)
    eint
    bis     #0x0018, r2

<span style="color: #ff6600;">siren</span>:
    bic.b   #0x01, &amp;TACCTL1     ; clear interrupt
    xor.b   #0x01, &amp;P1DIR       ; toggle red
    xor.b   #0x40, &amp;P1DIR       ; toggle green
    reti

<span style="color: #c0c0c0;">__noint</span>:
    reti

.section .vectors, "a" ; Set attribs CONTENTS, ALLOC, LOAD, READONLY, DATA
    .word __noint, __noint, __noint, __noint
    .word __noint, __noint, __noint, __noint
    .word <span style="color: #ff6600;">siren</span>,   __noint, __noint, __noint
    .word __noint, __noint, __noint, <span style="color: #ff6600;">main</span></pre>
<p></code></p>
</div>
<p>As you may have noticed, our interrupt vector table contains a lot of references to <strong>__noint</strong>.  That's good code-practice. If another interrupt is raised (for whatever reason, e.g. due to a bug), then we'll make sure that we run "reti" (return from interrupt) immediately, to handle it cleanly. This can often help with debugging, as sometimes you'd want to do something before the reti, and set a breakpoint to catch it.</p>
<p>You'll also notice that we're setting the CPU into LPM0 mode, aka "low power mode 0", and it simply means that we are only running the SMCLK and ACLK clocks on our chip.  We've basically switched off the CPU. That's one of the cool features of the MSP, i.e. that you can enable the CPU (MCLK) when you need it, and you can even increase the clock frequency as needed as well for those computationally intensive moments, only to lower it shortly after to save battery.</p>
<p>Lastly, here is a video of the demo.  I do sincerely apologize for the horrible video quality. <img src='http://blog.rasterburn.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><object width="550" height="438"><param name="movie" value="http://www.youtube.com/v/HyrMGvp1YDk?version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/HyrMGvp1YDk?version=3" type="application/x-shockwave-flash" width="550" height="438" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Compiling and deploying the app is the same procedure as before:</p>
<div style="background-color: black; color: #c0c0c0;"><code>
<pre>
$ msp430-as -o test.o -mmsp430x2012 test.asm
$ msp430-ld -o test.elf -T test.map test.o
$ mspdebug rf2500 "prog test.elf"
[..snip snip..]
Programming...
Writing  82 bytes to f800...
Writing  32 bytes to ffe0...
$
</pre>
<p></code></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.rasterburn.org/?feed=rss2&#038;p=97</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with a chip from Texas Instruments [part 1]</title>
		<link>http://blog.rasterburn.org/?p=80</link>
		<comments>http://blog.rasterburn.org/?p=80#comments</comments>
		<pubDate>Mon, 30 May 2011 18:42:42 +0000</pubDate>
		<dc:creator>TK</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.rasterburn.org/?p=80</guid>
		<description><![CDATA[msp430 blinking program assembly tutorial]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.msp430launchpad.com/">I've found this really cool chip.</a> It's from Texas Instruments and it's called the MSP430. It's got a 16-bit RISC CPU inside of it, capable of different power modes (including ultralow power, down to 0.7µA at 1MHz!). You can even power this thing off a couple of AA batteries. You can get a development kit called the Launchpad for a subsidized price of approx $5 USD.</p>
<p>I run OS X (the same applies if you run Linux) so I could not run the Windows-based IDE that comes with the MSP chip.  That's fine, because in this case I prefer my command-line tools anyway. In fact, to learn as much as possible about this chip, I wanted to get down to the bare metal and code some assembly!</p>
<p>So what do we need?  Well, we need an assembler, a linker and a device programmer tool. I'm going to be using the <a href="http://carnelec.com/msp_osx/mspgcc_on_osx.xhtml">GNU assembler and linker</a>, along with <a href="http://mspdebug.sourceforge.net">mspdebug</a>. (Use the links mentioned to get started).</p>
<p>Secondly, we need the official specs and datasheets in order to learn as much as possible about the CPU.  The most important one is the user manual, which I've uploaded <a href="http://www.rasterburn.org/~sgt/stuff4/MSP430/msp430-usermanual.pdf">here</a>.</p>
<p>Now let's begin. We first need to tell the linker about the memory map for the executable that we are going to produce.  Looking at the MSP's memory map, we can see that code memory begins at 0xF800 and we are given 2kB of this code space.  The interrupt vector table begins at 0xFFE0, and is exactly 32 bytes.  There are different MSP chips with slight differences, e.g. the G2031 only has 512 bytes of code memory.  The best thing is to have a look at the datasheet for the chip you'll be using (look for "Memory Organization").  I'm using the MSP<strong>G2231</strong> chip.</p>
<p>Let's call this file test.map:</p>
<div style="background-color: black; color: #c0c0c0;"><code></p>
<pre><span style="color: #ff9900;">MEMORY</span>
{
        TEXT    : ORIGIN = 0xf800, LENGTH = 0x0800
        DATA    : ORIGIN = 0x1000, LENGTH = 0x0100
        VECTORS : ORIGIN = 0xffe0, LENGTH = 0x0020
}

<span style="color: #ff9900;">SECTIONS</span>
{
        .text : { *(.text) } &gt; TEXT
        .data : { *(.data) } &gt; DATA
        .vectors : { *(.section .vectors) } &gt; VECTORS
        .bss : { *(.bss) }
}</pre>
<p></code></p>
</div>
<p>With this map file we're basically telling the linker that when it produces the final ELF executable, the target device needs to put the code data on 0xF800 (2kB space available), the interrupt vectors on 0xFFE0 and so on.  Don't worry about the .bss section and the .data section for now, as in our first example we won't be using them.</p>
<p>Now, let's proceed with our first test program!  Call this file test.asm.</p>
<div style="background-color: black; color: #c0c0c0;"><code></p>
<pre>.global <span style="color: #ff9900;">main</span>

.set    WDTCTL,     0x0120          ; watchdog control port
.set    WDTPW,      0x5A00          ; watchdog power
.set    WDTHOLD,    0x0080          ; watchdog hold
.set    P1DIR,      0x0022          ; direction of data bits on port P1

.text
<span style="color: #ff9900;">main</span>:
    mov     #0x0280, r1             ; set stackpointer to top of RAM
    mov     #WDTPW+WDTHOLD, &amp;WDTCTL ; stop watchdog
    bis.b   #0x41, &amp;P1DIR           ; lights up red LED and also green LED

    jmp $+0                         ; we are done

.section .vectors, "a" ; Set attribs CONTENTS, ALLOC, LOAD, READONLY, DATA
    .word 0x00, 0x00, 0x00, 0x00
    .word 0x00, 0x00, 0x00, 0x00
    .word 0x00, 0x00, 0x00, 0x00
    .word 0x00, 0x00, 0x00, main</pre>
<p></code></p>
</div>
<p>Note that with the GNU assembler, any section that is not .text, .data, .bss, and so on, has to be added with ".section" (or .sect), this is unlike other assemblers.</p>
<p>Let's start with the bottom section - the .vectors section - just to get it out of the way. As you may remember, the interrupt vector table is 32 bytes (it is in fact 64 bytes on my chip, but I don't need to worry about the additional 32 bytes right now).  The only vector I need is the RESET vector, and you'll see that I've pointed the last word (2 bytes) to main's address!  Without this, you won't get very far.  Also note that the section has got the "a" attribute. This is just so that the linker will include the .vectors section in the ELF executable that we'll be producing.</p>
<p>Let's have a look at the main procedure. Setting the stack pointer (SP is the same as the R1 register) at the top of RAM is a part of the initialization. We also stop the watchdog, although this code would have worked without it.  The "BIS" instruction sets Port 1.0 (red LED) Port 1.6 (green LED) to ON, so that they are lit.</p>
<p>Let's translate the assembly code to object code!</p>
<div style="background-color: black; color: #c0c0c0;"><code></p>
<pre>$ msp430-as -o test.o -mmsp430x2012 test.asm</pre>
<p></code></p>
</div>
<p>Now we have test.o, although it's an ELF executable, it won't run on the target device.  We'll need to run the linker on it, referring to our memory map file (test.map).</p>
<div style="background-color: black; color: #c0c0c0;"><code></p>
<pre>$ msp430-ld -o test.elf -T test.map test.o</pre>
<p></code></p>
</div>
<p>Great. Now we've got the ELF executable, which we will upload and run this using the 'mspdebug' tool, as follows:</p>
<div style="background-color: black; color: #c0c0c0;"><code></p>
<pre>$ mspdebug rf2500 "prog test.elf"
[..snip snip.]
Programming...
Writing  18 bytes to f800...
Writing  32 bytes to ffe0...
$</pre>
<p></code></p>
</div>
<p>Voila, we got the end result.  Both the green LED as well as the red one are now lit.  A very primitive program indeed, but at least now we've sorted out how to use the GNU assembler/linker along with mspdebug to code assembly for the MSP430 chips.  In the next article we'll do something more interesting!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rasterburn.org/?feed=rss2&#038;p=80</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Scala 2.8 and NetBeans 6.9 on Mac OS X</title>
		<link>http://blog.rasterburn.org/?p=60</link>
		<comments>http://blog.rasterburn.org/?p=60#comments</comments>
		<pubDate>Mon, 07 Feb 2011 09:46:24 +0000</pubDate>
		<dc:creator>TK</dc:creator>
				<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://blog.rasterburn.org/?p=60</guid>
		<description><![CDATA[scala netbeans ide mac osx erlybird]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.rasterburn.org/wp-content/uploads/2011/02/10263773381015152.png"><img class="aligncenter size-full wp-image-61" title="Scala logo" src="http://blog.rasterburn.org/wp-content/uploads/2011/02/10263773381015152.png" alt="" width="200" height="57" /></a></p>
<p>I decided to check out the Scala programming language and seeing that my favorite IDE is NetBeans, I wanted to keep using it for Scala development.</p>
<p>The steps required to do this are the following:</p>
<ol>
<li>Download Scala from <a href="www.scala-lang.org/downloads">www.scala-lang.org/downloads</a>, uncompress in say ~/scala-2.8.1.final.  I like to make a symlink from ~/scala-2.8.1.final to ~/scala</li>
<li>Edit your ~/.profile and set the environment variable SCALA_HOME to be $HOME/scala.  Also add $SCALA_HOME/bin to your PATH variable.</li>
<li>Now, go to <a href="http://sourceforge.net/projects/erlybird/files/">http://sourceforge.net/projects/erlybird/files/</a> and get your Scala plugin. Uncompress and you will find lots of NBM files.</li>
<li>Start NetBeans, go to Tools/Plugins/Downloaded.  Click "Add plugins" and select the NBM files from step 3.  Now you have the plugin installed.</li>
<li>Finally, create a folder ~/.MacOSX (unless it already exists) and within it, create a file called environment.plist.  The contents of this file follows:</li>
</ol>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
&lt;key&gt;SCALA_HOME&lt;/key&gt;
&lt;string&gt;/Users/tk/scala&lt;/string&gt;
&lt;key&gt;PATH&lt;/key&gt;
&lt;string&gt;/Users/tk/scala/bin:/whatever/other/paths/you/may/have:/usr/local/bin&lt;/string&gt;
&lt;/dict&gt;
&lt;/plist&gt;</pre>
<p>You're done.  Let's log out and then log back in.  Start NetBeans and create a new Scala project, see if auto-completion etc. works.<br />
<a href="http://blog.rasterburn.org/wp-content/uploads/2011/02/scalaexample.png"><img class="aligncenter size-full wp-image-70" title="scalaexample" src="http://blog.rasterburn.org/wp-content/uploads/2011/02/scalaexample.png" alt="" width="339" height="409" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rasterburn.org/?feed=rss2&#038;p=60</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Diving into the IBM &#8211; Invoking ROM BASIC!</title>
		<link>http://blog.rasterburn.org/?p=33</link>
		<comments>http://blog.rasterburn.org/?p=33#comments</comments>
		<pubDate>Thu, 06 Jan 2011 20:14:11 +0000</pubDate>
		<dc:creator>TK</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.rasterburn.org/?p=33</guid>
		<description><![CDATA[ibm xt 8088 rom basic attempt]]></description>
			<content:encoded><![CDATA[<p>The IBM XT 8088 comes with something called "<strong>ROM BASIC</strong>", however I couldn't seem to access it via MS-DOS.  <span style="color: #ff0000;">[<strong>Note: </strong>Source code now available, see comment below]</span></p>
<p><img class="size-full wp-image-39 alignright" title="ibm xt 8088" src="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1453-1.jpg" alt="" width="230" height="384" /></p>
<p>Initially, it seemed to be inaccessible unless you are willing to remove the harddrive and reboot.  So I set out on a mission; I wanted to access it from within MS-DOS!  The value of all this?  Weeeell...  Hey, it's a challenge.</p>
<p style="text-align: center;">
<p>I read up on the specific interrupt you need to trigger ROM BASIC, and it is INT 18h.</p>
<p>However, it's not as easy as that. I started up DEBUG, punched a few assembly instructions so I could trigger INT 18h.  It responded, and sure enough I got ROM BASIC.  <span style="color: #ff0000;"><strong>Unfortunately, the keyboard input was not working at all!</strong></span></p>
<p>I consulted some friendly peeps at <em>comp.lang.asm.x86</em> and they told me the whole IVT (interrupt vector table) had to be replaced with the one present before MS-DOS replaces it with its own IVT.  In other words, I needed the default BIOS IVT table, otherwise I would be calling the DOS keyboard interrupt routines instead of the BIOS keyboard routines.</p>
<p style="text-align: center;">
<p style="text-align: center;">
<p style="text-align: center;"><img class="size-full wp-image-38 aligncenter" title="Hand written assembly code..." src="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1452.jpg" alt="" width="480" height="288" />I temporarily removed the harddrive, and started the computer so that ROM BASIC came up.  I then wrote a little BASIC program to dump the entire IVT contents as hexadecimal codes to screen. 100 at a time. Just enough so that I could take a photograph of each screen.  (I don't have any means of connecting the XT to one of my other modern machines!).</p>
<p><img class="alignnone size-full wp-image-46" title="IVT table manually typed and then printed" src="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1472.jpg" alt="" width="640" height="384" /></p>
<p>Typing it all in on my Mac later, I started to make sense of it, and finally printed it all out, including my prototype 8088 program (yes, on old fashioned paper. And yes, this took way too long and my fingers hurt afterwards).  Tricky stuff. I got some friendly advice from the guys in <em>comp.lang.asm.x86</em> to keep me going further after nearly giving up (<span style="color: #339966;">Thanks Bob, Rod, Frank</span>!).  My knowledge of assembly isn't the greatest so this endeavour forced me to learn a whole LOT.</p>
<p style="text-align: center;"><a href="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1462.jpg"><img class="size-full wp-image-44 aligncenter" title="Asm code in DEBUG" src="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1462.jpg" alt="" width="640" height="426" /></a></p>
<p>Some glimpses of my assembly code.</p>
<p style="text-align: center;"><img class="size-full wp-image-43 aligncenter" title="DSC_1458" src="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1458.jpg" alt="" width="640" height="385" /></p>
<p>Then, I finally got it to work, with keyboard working - as you can see below!</p>
<p style="text-align: center;"><img class="size-full wp-image-45 aligncenter" title="Yay it works" src="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1469.jpg" alt="" width="481" height="800" /></p>
<p>Ok, hmm, I spent way too much time on this!  However, I'm glad it's over and done with now.  I think it's cool that there is so much direct access to the hardware and to the memory with these old machines.  Perhaps it's time to revive my Amiga now.    [<span style="color: #888888;">PS: Full code will be posted shortly, just need to type it all in<span style="color: #000000;">]</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rasterburn.org/?feed=rss2&#038;p=33</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trip to Modalen with my dad</title>
		<link>http://blog.rasterburn.org/?p=21</link>
		<comments>http://blog.rasterburn.org/?p=21#comments</comments>
		<pubDate>Wed, 05 Jan 2011 22:20:54 +0000</pubDate>
		<dc:creator>TK</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.rasterburn.org/?p=21</guid>
		<description><![CDATA[modalen photography trip]]></description>
			<content:encoded><![CDATA[<p>A few days ago I went to Modalen on a photo expedition with my cool dad.  You can see him below!  Weather was great for taking photos..  Sorry that the photos are a bit huge this time, I will avoid that next time I post photos.</p>
<p><a href="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1349.jpg"><img class="alignnone size-full wp-image-27" title="DSC_1349" src="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1349.jpg" alt="" width="554" height="720" /></a></p>
<p><a href="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1349.jpg"></a><a href="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1347.jpg"><img class="alignnone size-full wp-image-26" title="DSC_1347" src="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1347.jpg" alt="" width="416" height="720" /></a></p>
<p><a href="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1347.jpg"></a><a href="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1385.jpg"><img class="alignnone size-full wp-image-29" title="DSC_1385" src="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1385.jpg" alt="" width="728" height="1200" /></a><a href="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1350.jpg"><img class="alignnone size-full wp-image-28" title="DSC_1350" src="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1350.jpg" alt="" width="884" height="1200" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rasterburn.org/?feed=rss2&#038;p=21</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dusting off the IBM</title>
		<link>http://blog.rasterburn.org/?p=13</link>
		<comments>http://blog.rasterburn.org/?p=13#comments</comments>
		<pubDate>Wed, 05 Jan 2011 22:04:31 +0000</pubDate>
		<dc:creator>TK</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.rasterburn.org/?p=13</guid>
		<description><![CDATA[ibm xt 8088 memory chips]]></description>
			<content:encoded><![CDATA[<p>My dad bought an IBM XT 8088 a long time ago, in the 80s sometime.  This was my first introduction to computing so I have fond memories of this machine.  It clocks in at 4.77Mhz on its Intel 8088 CPU.  A mind-boggling 640kB memory keeps you satisfied for a lifetime.</p>
<p><a href="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1453.jpg"><img class="alignnone size-full wp-image-15" title="ibm xt 8088" src="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1453.jpg" alt="" width="431" height="720" /></a></p>
<p>Being home this Christmas vacation (December 2010) I figured it's time to take it down from the attic and see if it boots up!  I first vacuumed it and cleaned all the circuit boards with a brush, so there wouldn't be a hint of dust anywhere.</p>
<p>I cranked the ol' beast up it and it said BAM.  Followed by a bit of white smoke.  I still don't know what happened, but after the 2nd boot, it booted straight up and started MS-DOS.  However, unfortunately only 192kB of the original 640kB was recognized, so some of the memory chips were clearly faulty.  As for the BAM! sound, it must have come from somewhere else. To my knowledge, RAM chips don't fail with a loud noise and burned scent!</p>
<p><a href="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1318.jpg"><img class="alignnone size-full wp-image-14" title="Memory expansion card and faulty chips" src="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1318.jpg" alt="" width="840" height="559" /></a></p>
<p><a href="http://blog.rasterburn.org/wp-content/uploads/2011/01/DSC_1318.jpg"></a>I thus started hunting the faulty chips, and finally found the two sinners.  Two nasty 4164 chips (contains 65536 bits each).   However, this meant that all the other chips on the same bank would have to be taken out as well.  So I ended up with an acceptable 576kB of working memory.</p>
<p>Stay tuned for more exciting vintage computing stories!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rasterburn.org/?feed=rss2&#038;p=13</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
