Herunterladen Inhalt Inhalt Diese Seite drucken

Cctl0 Enabled, Cctl1 Enabled Mit (Ta)Ccr1 = (Ta)Ccr0/2 Und Tai Im Tactl Gesetzt - Texas Instruments MSP430 Anleitung

Vorschau ausblenden Andere Handbücher für MSP430:
Inhaltsverzeichnis

Werbung

FH-Köln Campus Gummersbach
Beispiel 2:
9.5.2 CCTL0 enabled, CCTL1 enabled mit (TA)CCR1 = (TA)CCR0/2 und TAI im TACTL
gesetzt
#include <msp430G2231.h>
int X = 0;
unsigned int TimeValue = 10000;
void INIT();
//-----------------------MAIN PROGRAM--------------------------------
int main( void )
{
if (X==0)
{
INIT();
X = 1;
}
while (1); //Non ending loop
}
//----------------------SUBROUTINES----------------------------------
void INIT()
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
//..............Port configuration....................
P1DIR = 0x7F; //P1.0..P1.6 outputs / P1.7 Input
P1OUT = 0x00; //Delete all outputs
P1IE = 0x80; //Interrupt Enable P1.7
P1IFG = 0x00; //eventuelle Interrupt-Flags löschen
P1IES = 0x80; //High -> low Interrupt
P1IFG = 0x00; //Reset Hardware IRQ
//.....................................................
//..............Timer configuration...................
TACTL = MC_0;
//Optional: Reset Mode
CCR0 = 0x00;
//Optional: Reset
CCR1 = 0x00;
//Optional: Reset
CCTL0 = CCIE;
// CCR0 interrupt enable
CCTL1 = CCIE;
// CCR1 interrupt enable
CCR0 = TimeValue; // Set period to CCR0 = x clock ticks
CCR1 = TimeValue/2; //CCR1 = CCR0/2 (half time as CCR0)
_BIS_SR(GIE);
// General Interrupt enable
TACTL = TASSEL_2 + MC_1 + TAIE + TACLR + ID_3; //Start Timer
//By using this configuration (TASSEL_2, MC_1 and ID_3
Juni 2012
MSP430 Mikrocontroller
25 |
S e i t e

Quicklinks ausblenden:

Werbung

Inhaltsverzeichnis
loading

Inhaltsverzeichnis