2013 with graphic display, just for fun.

TI製MSP430及び関連ハードウエア日英掲示板
Discussions about MSP430 and hardware peripherals (english - japanese)

2013 with graphic display, just for fun.

Postby pascal » Sun Mar 11, 2007 9:22 pm

Hello!

Today was a cold Sunday in Kyoto. Nothing to do except sleeping...
But I remembered having received a development board by Texas
Instruments, with 1 FG4618 and 1 F2013. This one:

Image

So I thought... would a SPI graphic display fit on a 2013.
Well, 2 KBytes flash, enough to store character information and some
extra code... So I decided to have a test run.

I printed out the schematic of the board and also a documentation of
the 2013.
Basically, for the LCD, I needed 5 signals: SCLK, MOSI, RS, CS and RESET.

Hardware

SCLK = serial clock
MOSI = master out, slave in (in this case 2013 out, LCD in)
RS = register select. Send a command if low, send data if high.
CS = Chip select
Reset = what it claims. Active low.

Now on the printed circuit, there are 4 lines going out of the 2013 and that
can be soldered: pins 6, 7, 8, 9 are wired to the connector H1, so we can
stick wires on them. Then, for the last one, There is one pad of the
capacitor C14 which is easily accesssible.

So I decided the following pin assignment

LCD 2013
SCLK <-> Pin 7 (SCLK)
MOSI <-> Pin 8 (SD0)
RS <-> Pin 6 (P1.4)
CS <-> Pin 9 (P1.7)
Reset <-> Pin 5 (P1.3)

Well, I have wired as if I was about to use the serial port, but in fact there
was also something I wanted to try for a while: trying to use my SPI LCD
from a plain old GPIO port. So I am going to use the GPIO.

After half an hour looking for lead-free solder, double face tape, etc in
my mess, I started to solder the flat cable adaptor. I have soldered one
side only because the prototyping area is extremely small.

Image

Then I added a small block of wood with double side tape.

Image

Then I stuck the LCD on it and that was about it:

Image

In fact, I did something else. The LCD is rated from 2.9V to 3.6V.
But with the 2 AAA batteries, there was only 2.6V, so I decided
to change the power supply to get 3.3V.

The software

I have reused a large part of the driver I wrote for Soroban
(see on this site in the products area). I have eliminated all the
unnecessary functions in order to have the code within the 2K
of the 2013.
The only part I really had to write from scratch was a new SPI made
from a GPIO.
So my GPIOSPI.h looks like this:

Code: Select all
#ifndef _GPIO_SPI_H_
#define _GPIO_SPI_H_

#define SCLK 0x20  // Port 1.5
#define MOSI 0x40  // Port 1.6
#define RS 0x10    // Port 1.4
#define CS 0x80    // Port 1.7
#define RESET 0x08 // Port 1.3

// Public functions
void InitGpioSpi(void);
void GpioSpiSendByte(uint8 byte);
void GpioSpiSendBuffer(uint8 * buffer, uint8 length)

#endif


Now the implementation of this file is simple:
Code: Select all
#include "GpioSpi.h"

// Local functions
// This function simply sets the clock high and then low.
void clock_spi(void);
// This function sends a single bit, 1 if val is nonzero, zero otherwise
void send_bit(uint8 val);

// A useful buffer of bits, MSB first
static const uint8 BIT[] {
    0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
}

void GpioSpiSendByte(uint8 byte) {
    uint8 i;
    for(i = 0 ; i < 8 ; ++i) send_bit(byte & BIT[i]);
}

void GpioSpiSendBuffer(uint8 * buffer, uint8 length) {
    uint8 i;
    for(i = 0 ; i < length ; ++i) {
        GpioSpiSendByte(*buffer++);
    }
}

// Sets the clock bit high, then low
void clock_spi() {
    P1OUT |= SCLK;
    P1OUT &= ~SCLK;
}

// Sends a single bit on MOSI
void send_bit(uint8 val) {
    // Set the MOSI depending on the bit value
    if(val) P1OUT |= MOSI;
    else P1OUT &= ~MOSI;
    // Send a clock to SCLK
    clock_spi();
}



That's it, the SPI implementation from a GPIO is as simple as this.
Note that I just wanted to prit to the screen and that I didn't need to
read the SPI port. This should be almost as easy.

Now here is the result of this development:

Image

When using 5x8 pixels characters, we can have 8 lines of 17 characters.

Well, now as for the next things to do with this demo:

1. Write simple graphic routines;
2. Translate this article into Japanese. (please givve me a few days!).

Thanks for your attention and thanks for reading until here.

Pascal
Last edited by pascal on Sun Oct 07, 2007 3:29 pm, edited 3 times in total.
pascal
Site Admin
 
Posts: 216
Joined: Sun Mar 04, 2007 11:47 am

Addendum

Postby pascal » Sun Mar 18, 2007 5:52 pm

Hello,

I would like to add a few lines to introduce you to Hamayan's blog.
(Hamayan is a nickname). He used this display and made a few funny
developments with images.

http://blog.so-net.ne.jp/hamayan/
It's in Japanese, but you can certainly view images of what he developed

Browse his blog. Beside this display, there are other interesting
development reports.

Pascal
pascal
Site Admin
 
Posts: 216
Joined: Sun Mar 04, 2007 11:47 am

Re: 2013 with graphic display, just for fun.

Postby jradomski » Sun Apr 22, 2007 8:10 pm

pascal wrote:// Sends a single bit on MOSI
void send_bit(uint8 val) {
// Set the MOSI depending on the bit value
if(val) P1OUT |= MOSI;
else P1OUT $= ~MOSI;
// Send a clock to SCLK
clock_spi();
}

[/code]


Pascal


shouldn't the $= be &=
jradomski
 
Posts: 6
Joined: Fri Apr 13, 2007 5:51 pm

Postby pascal » Sun Apr 22, 2007 8:59 pm

Hello!

shouldn't the $= be &=


Oops, you're right. Anyway those who might have tried that had a
compile error. I'll fix it right now.

Thanks,

Pascal
pascal
Site Admin
 
Posts: 216
Joined: Sun Mar 04, 2007 11:47 am


Return to MSP430 & peripherals hardware

Who is online

Users browsing this forum: No registered users and 0 guests

cron