顯示具有 MSP430 標籤的文章。 顯示所有文章
顯示具有 MSP430 標籤的文章。 顯示所有文章

2016年10月24日 星期一

MSP430 LaunchPad Timer_0 Interrupt

Using Timer_0 Interrupt to Toggle LED on MSP430 LaunchPad


#include <msp430.h>

#define OUTPUT_PIN  BIT0
/*
 * main.c
 *
 *  Testing timer_0 interrupt to toggle LED (P1.0)
 */

int main(void) {
    WDTCTL = WDTPW | WDTHOLD;   // Stop watchdog timer

    P1DIR |= OUTPUT_PIN; // Set P1.0 and P1.6 to output direction
    P1OUT |= OUTPUT_PIN;
    P1OUT ^= (OUTPUT_PIN);


    BCSCTL1 = CALBC1_8MHZ;
    DCOCTL = CALDCO_8MHZ;

    CCTL0 = CCIE;
    TACTL = TASSEL_2 + ID_3 + MC_1;     // Set the timer A to SMCLCK, UP to TACCR0, Input Divider: /8
    TACCR0 = 50000-1;       // 50ms @(8MHz/8)

    __enable_interrupt();

    __bis_SR_register(LPM0 + GIE); // LPM0 with interrupts enabled
    while(1);
}

// Timer A0 interrupt service routine
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A (void)
{
    static unsigned char ucCount = 0;
    if(ucCount++ >= 20){
        P1OUT ^= OUTPUT_PIN;
        ucCount = 0;
    }

}

2015年9月29日 星期二

Energia : using hardware UART

Using LaunchPad MSP-EXP430G2
MCU: M430G2553

problem:
Serial Monitor can't get the data from LaunchPad

Solution:
  Connecting to the USB2.0 hub port instead of connecting to USB3.0 port. If it still not works, trying another USB2.0 hub port.


使用 LaunchPad 時, Serial Monitor 一直無法看到 UART 傳來的資料.
後來使用 USB2.0 hub 連接 LaunchPad , Serial Monitor 就可收到 UART 的資料.