retrocoder.se

Login

MSP430 start project

Posted 2017-03-07 20:03:24

Today I will give you an walk-through of a small microcontroller project that I have started to work on.

On a breadboard I have set up a number of LED's to be controlled by an Texas Instruments MSP430. This initial setup is a test to see how many of the pins that can be used as digital outputs. I am using an ez430 evaluation board that has an MSP430-F2013 chip. This chip has 14 pins and 10 can be used as digital outputs at the same time. Of the four pins that can't be used as I/O, two is of course supply voltage and ground and then two pins has other functions.

The datasheet of this chip can be found on Texas Instruments webpage: http://www.ti.com/tool/ez430-F2013

Anyway the reason for this test setup is that I want to use the chip to control an LCD display. This display is controlled by a Hitachi HD44780 display controller. This display has a total of 14 connections, of which 11 is a parallel interface to communicate with it. The communication can also be done using only 7 connections. This means that the 10 digital outputs from the MSP430 is enough to be able to get something displayed. This is the final goal of the project and will be the subject of a coming article here on retrocoder.se

But at the moment the MSP430 only controlls LEDs and the program I have written is a short assembly program looping over the outputs toggling them on and off, one at a time.

This is the code:

;******************************************************************************
;   MSP-FET430F2013 Demo - Blink with several LED's
;
;   Description: Drive many LED's
;   ACLK = n/a, MCLK = SMCLK = default DCO ~800kHz
;
;                MSP430F2013
;             -----------------
;           -|VCC           VSS|-
;            |                 |
;     LED <--|P1.0         P2.6|--> LED
;            |                 |
;     LED <--|P1.1         P2.7|--> LED
;            |                 |
;     LED <--|P1.2             |-
;            |                 |
;     LED <--|P1.3             |-
;            |                 |
;     LED <--|P1.4         P1.7|--> LED
;            |                 |
;     LED <--|P1.5         P1.6|--> LED
;             -----------------
;   j.karlsson@retrocoder.se
;   R-Design
;   October 2016
;******************************************************************************
 .cdecls C,LIST,  "msp430.h"

;------------------------------------------------------------------------------
            .text                           ; Progam Start
;------------------------------------------------------------------------------
RESET       mov.w   #0280h,SP               ; Initialize stackpointer
 .export RESET;
StopWDT     mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop WDT
Setup       bis.b   #0xFF,&P1DIR            ; P1.x  output
            bic.b   #0xFF,&P1OUT            ;
            bic.b   #0xC0,&P2SEL            ;
            bis.b   #0xC0,&P2DIR            ; P2.x  output
            bic.b   #0xC0,&P2OUT

Mainloop    bis.b   #0x1,&P1OUT             ; Switch on first LED on P1
            mov.b   #0x3, R14               ;
            call    #Wait1mysec             ;
P1_loop     xor.b   R14,&P1OUT              ; Toggle P1.x
            call    #Wait1mysec             ;
            clrc;
            rlc.b   R14                     ;
            jnc     P1_loop                 ; Jump if carry clear
            xor.b   R14,&P1OUT              ; Switch off last LED on P1

            mov.b   #0x60, R14              ; Run sequence on P2
P2_loop     xor.b   R14,&P2OUT              ; Toggle P2.x
            call    #Wait1mysec             ;
            clrc;
            rlc.b   R14                     ;
            jnc     P2_loop                 ;
            xor.b   R14,&P2OUT              ; Switch off last LED on P2
            jmp     Mainloop                ; Again
                                            ;
Wait1mysec  push sr                         ;
            mov.w   #0xA000,R15             ; Delay to R15
L1          dec.w   R15                     ; Decrement R15
            jnz     L1                      ; Delay over?
            pop sr                          ;
            ret                             ;
Wait1sec    mov.w   #0xFFFF,R15             ; Delay to R15
L2          dec.w   R15                     ; Decrement R15
            jnz     L2                      ; Delay over?
            ret                             ;

;------------------------------------------------------------------------------
;           Interrupt Vectors
;------------------------------------------------------------------------------
            .sect   ".reset"                ; MSP430 RESET Vector
            .short  RESET                   ;
            .end

There is a short youtube video that shows this setup that you can watch below.


Before I continue with the display part I thought that I will use the LED setup to do some more fun with it. If I arrange the LEDs in a dice pattern, using 7 of them, I can implement an electronic dice. I will implement a random number generator to decide what to show on the dice. I will post an article here as soon as this is ready.

This was all for this time, hope to see you soon again.

//retrocoder