반응형

Pin Diagram

레지스터 설정 설명

1) GPIO(x = 1,2)

: Port 1,2 I/O 설정

  • PxDIR: Input, Output 설정 / I:0, O:1
  • PxSELy(x,y = 1,2)
    : GPIO 혹은 Peripheral Funtion 설정 / PxSEL PxSEL2 0으로 설정해야 일반 I/O 사용할 있다.
    : PxSEL 1 경우, Peripheral 사용 가능, PWM 사용 해당 1 설정

  • PxREN
    : Resistor Pullup/pulldown resistor 설정 / Disable:0, Enable:1
    : Input 사용하며 PxREN을 설정하여 풀업, 풀다운 저항을 설정할 수 있다. (Common High or Low)

 

  • PxIN: Input
  • PxOUT: Ouput
  • PM5CTL0 &= ~LOCKLPM5;
    : MSP430F Series FRAM 모델로서 전원이 인가된 PM5CTL0 LOCKLPM5 bit 0으로 만들어 I/O 설정을 있도록 한다.

EX)

P1DIR |= 0b00000010  ->  Port1 Bit2 Output으로 설정

P1OUT = 0xFF  ->  Port1 모든 Bit ON

P2OUT |= 0x04  -> Port2 Bit3 ON

P2OUT &= ~0x10  ->  Port2 Bit4 OFF

 

2) Timer (x,y = 0,1)
: MSP430G2333 경우, Timer A,B A 있음(참고. Pin Diagram)

  • MCLK
    :Master Clock; MCU의 메인 Core에 사용되는 클럭
  • SMCLK
    : Sub-Main Clock; 주로 고속이 필요한 Peripheral 에 클럭을 공급
  • DCO
    : 디지털 입력 값을 받아 특정 주파수의 발진 클럭을 만듦
  • DCO (The digitally controlled oscillator)
  • DCO 최대 16MHz 이며, 1, 8, 12, 16으로 설정 가능

EX)

//DCO 16Mhz
if (CALBC1_16MHZ==0xFF)       // If calibration constant erased
{
    while(1);                 // do not load, trap CPU!!
}
DCOCTL = 0;                   // Select lowest DCOx and MODx settings
BCSCTL1 = CALBC1_16MHZ;       // Set range
DCOCTL = CALDCO_16MHZ;        // Set DCO step + modulation*/

 

 

  • TAxCTL
    : Timer Control; Mode, Input Divider, Clock Source Select 가지로 나누어 설정

EX)

Timer0 A3, SMCLK / 4 , Up mode  ->  TA0CTL = TASSEL_2 + MC_1 + ID_2;

#define MC_0                   (0*0x10u)      /* Timer A mode control: 0 - Stop */
#define MC_1                   (1*0x10u)      /* Timer A mode control: 1 - Up to CCR0 */
#define MC_2                   (2*0x10u)      /* Timer A mode control: 2 - Continous up */
#define MC_3                   (3*0x10u)      /* Timer A mode control: 3 - Up/Down */
#define ID_0                   (0*0x40u)      /* Timer A input divider: 0 - /1 */
#define ID_1                   (1*0x40u)      /* Timer A input divider: 1 - /2 */
#define ID_2                   (2*0x40u)      /* Timer A input divider: 2 - /4 */
#define ID_3                   (3*0x40u)      /* Timer A input divider: 3 - /8 */
#define TASSEL_0               (0*0x100u)     /* Timer A clock source select: 0 - TACLK */
#define TASSEL_1               (1*0x100u)     /* Timer A clock source select: 1 - ACLK  */
#define TASSEL_2               (2*0x100u)     /* Timer A clock source select: 2 - SMCLK */
#define TASSEL_3               (3*0x100u)     /* Timer A clock source select: 3 - INCLK */

 

  • TAxCCRy
    : Timer x Capture/Compare y; PWM Period 설정 (16Bit)
    : UP mode일 때, TACCR0까지 Count
    : Continuous mode , 0FFFFh까지 Count

  • TAxCCTLy
    : PWM Output Mode (5,6,7 Bit) , Enable (4 Bit) 등등 설정 (16Bit)
    Output Mode = 2,3,6,7

 

 

P2.7을 I/O로 사용하도록 설정 – P2SEL

P2.7을 입력으로 설정 – P2DIR

P2.7의 인터럽트를 인에이블 – P2IE

P2.7의 인터럽트가 rising edge에서 발생하도록 설정 – P2IES

P2.7의 인터럽트 플래그를 0으로 리셋 – P2IFG : P2IFG를 세팅한 이후에 P2DIR이나 P2OUT에 쓰기를 실행하면 P2IFG에 영향을 줄 수 있으니 주의하자.

 

인터럽트 이네이블 레지스터 (PxIE)

• Bit = 0: 인터럽트 디세이블 설정

• Bit = 1: 인터럽트 이네이블 설정

 

인터럽트 에지 선택 레지스터 (PxIES)

• Bit = 0: low-to-high 설정

• Bit = 1: high-to-low 설정

 

Timer Interrupt 사용법

TA0_A0, TA0_A1, TA1_A0, TA1_A1

#pragma vector = TIMER0_A1_VECTOR
__interrupt void TIMER0_A1_ISR (void)
{

}

 

 

 

LPM: Low Power Mode

 

 

관련 링크

 

 

 

반응형

+ Recent posts