#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;
}
}
2016年10月24日 星期一
MSP430 LaunchPad Timer_0 Interrupt
Using Timer_0 Interrupt to Toggle LED on MSP430 LaunchPad
2016年8月25日 星期四
LME288 的處理方法
- Run command prompt as Administrator.
- Type (without quotes) "bcdedit /set IncreaseUserVa 3072"
- Reboot computer.
2016年7月19日 星期二
在 Batch File 中使用 findstr 比對 log 檔中的訊息
當 Batch File 需要判斷某個程式輸出的 log 檔內容時, findstr 是一個可用的工具.
目前用過的參數:
參數說明:
findstr /?
比對檔案中的文字
findstr /c:string filename
可用 ERRORLEVEL 判斷是否有符合字串.
ERRORLEVEL 為 0 時, 有符合字串.
ERRORLEVEL 為 1 時, 沒有找到符合字串.
--
ERRORLEVEL 的用法:
例如:
目前用過的參數:
參數說明:
findstr /?
比對檔案中的文字
findstr /c:string filename
可用 ERRORLEVEL 判斷是否有符合字串.
ERRORLEVEL 為 0 時, 有符合字串.
ERRORLEVEL 為 1 時, 沒有找到符合字串.
--
ERRORLEVEL 的用法:
IF ERRORRLEVEL N to check if the errorlevel is >= N. IF NOT ERRORLEVEL N to check if errorlevel is < N例如:
findstr /C:FFFF info_1.hex
IF ERRORLEVEL 1 goto NOT_MATCH
echo MATCH
goto END
:NOT_MATCH
echo NOT_MATCH
:END
Batch file 指令太長如何換行
當 Batch File 的一行太長要換行時, 加入 "^" (不含 ") , 緊接著換行就可以了.
例如:
寫成:
注意 "^" 一定要緊接著換行碼, 不能有空格!
例如:
echo off
IF "%1"=="" goto end
echo %1
:end
寫成:
echo off
IF "%1"=="" ^
goto end
echo %1
:end
注意 "^" 一定要緊接著換行碼, 不能有空格!
2016年7月5日 星期二
2016年7月1日 星期五
把 list 的資料寫入到 file
bytesToWrite=[125,3,255,0,101]
newfile=open("hello.bin",'wb')
newfile.write(bytes(bytesToWrite))
newfile.close()
訂閱:
文章 (Atom)