Herunterladen Inhalt Inhalt Diese Seite drucken

Texas Instruments MSP430 Benutzerhandbuch Seite 56

Education system v3.3
Vorschau ausblenden Andere Handbücher für MSP430:
Inhaltsverzeichnis
Nachfolgend der zusammenhängende Quelltext des ersten eigenen Programms:
// ****************************************************************************
///
\file continous-mode.s43
///
/// It seems, that this program uses Timer A to display a binary value via LEDs. It counts from
/// 0x00 to 0x0f (using P1.0,P1.1,P1.2 and P1.3). But Timer_A only switches LEDs depending on
/// Timer_A channel values and clock frequency.
///
/// \date 12.10.2005
///
/// \note To debug the program right click the project and choose "Options ...".
///
Select the category "Debugger" and change the driver to "FET Debugger"
// ****************************************************************************
#include <msp430.h>
;------------------------------------------------------------------------------
ORG
;------------------------------------------------------------------------------
RESET
mov.w
#300h,SP
StopWDT
mov.w
#WDTPW+WDTHOLD,&WDTCTL
SetupTA
mov.w
#TASSEL0+TACLR+TAIE,&TACTL
mov.w
#CCIE,&CCTL0
mov.w
#07FFFh,&CCR0
mov.w
#CCIE,&CCTL1
mov.w
#03FFFh,&CCR1
mov.w
#CCIE,&CCTL2
mov.w
#01FFFh,&CCR2
SetupP1
bis.b
#BIT0+BIT1+BIT2+BIT3,&P1DIR
mov.b
#0FFh,&P1OUT
StartTA
bis.w
#MC1,&TACTL
eint
Mainloop
bis.w
#LPM3,SR
nop
;------------------------------------------------------------------------------
TA_CCR0_ISR
;------------------------------------------------------------------------------
add.w
#07FFFh,&CCR0
xor.b
#BIT1,&P1OUT
reti
;------------------------------------------------------------------------------
TAX_ISR
;------------------------------------------------------------------------------
Handbuch MSP430 Education System
0E000h
Literatur- und Quellenverzeichnis
; Program Start
; Initialize stackpointer
; Stop WDT
; ACLK, Clear TAR,
; interrupt enable
; enable CCR0 compare interrupt
; initialize CCR0
; enable CCR1 compare interrupt
; initialize CCR1
; enable CCR2 compare interrupt
; initialize CCR2
; P1.0-P1.3 output
; P1 as output
; Start timer_A continous mode
; Enable interrupts
; MCLK is not required
; Required only for C-spy Simulator
; ISR for CCR0
; add CCR0 init value to CCR0
; toggle P1.1
; Common ISR for CCR1-4 and overflow
Seite 56

Quicklinks ausblenden:

Inhaltsverzeichnis
loading

Verwandte Produkte für Texas Instruments MSP430

Inhaltsverzeichnis