lpc1768 cortex-m3 mcpwmael.chungbuk.ac.kr/lectures/undergraduate/임베디드sw... · 2018. 10....

25
1 LPC1768 Cortex-M3 MCPWM

Upload: others

Post on 22-Sep-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

1

LPC1768 Cortex-M3 MCPWM

Page 2: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

2 345v09

개요 특징 The Motor Control PWM (MCPWM) is optimized for three-phase AC and DC motor

control applications but can be used in many other applications that need timing, counting, capture, and

comparison. The MCPWM contains three independent channels, each including: two modulated outputs (MCOA and MCOB) with opposite polarities a 32-bit Timer/Counter (TC) a 32-bit Match register (MAT) a 32-bit capture register (CAP)

Input pins MCI0-2 can trigger TC capture or increment a channel’'s TC.

관련 구조체 및 함수의 정의 MCPWM관련 구조체와 함수들은 drivers/include/lpc17xx_mcpwm.c와

drivers/source/lpc17xx_mcpwm.h에 정의되어 있다.

Page 3: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

3 345v09

주요 함수와 구조체의 상세 설명 MCPWM_Init() : MCPWM을 초기화 한다. 함수원형 : void MCPWM_Init (MCPWM_TypeDef *MCPWMx)

매개변수 : MCPWMx : 초기화할 MCPWM

상세설명 MCPWM을 사용하기 위해 장치를 초기화 하는 함수로 매개변수 MCPWMx는 초기화할

MCPWM을 선택하는 값이다. 현재 MCPWM 기능은 1개만 제공되고 있어서 매개변수에 설정할 수 있는 값은 MCPWM이 유일하다.

반환 값 : 없음

Page 4: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

4 345v09

주요 함수와 구조체의 상세 설명 MCPWM_ConfigChannel() : MCPWM의 각 채널별 동작을 설정한다. 함수원형 : void MCPWM_ConfigChannel (MCPWM_TypeDef *MCPWMx, uint32_t channelNum, MCPWM_CHANNEL_CFG_Type *channelSetup)

매개변수 : MCPWMx : 설정할 MCPWM channelNum : 설정할 MCPWM 채널번호 channelSetup : MCPWM 채널의 동작 설정값을 가지고 있는

MCPWM_CHANNEL_CFG_Type 구조체의 포인터 상세설명 MCPWM의 각 채널별 동작을 설정하는 함수로 매개변수 MCPWMx의 설정 값은

MCPWM이 유일하며, channelNum은 0~2 중에서 선택하여 동작을 설정할 채널을 정할 수 있다. channelSetup은 MCPWM 채널의 동작 설정 값을 저장하고 있는 구조체 MCPWM_CHANNEL_CFG_Type의 포인터로 MCPWM_ConfigChannel()함수에서는 channelSetup의 구조체에 저장된 설정사항으로 MCPWM 채널의 동작을 설정하게 된다.

반환 값 : 없음

Page 5: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

5 345v09

주요 함수와 구조체의 상세 설명 MCPWM_Start() : 각 채널별로 MCPWM의 동작을 시작한다. 함수원형 : void MCPWM_Start (MCPWM_TypeDef *MCPWMx, uint32_t channel0, uint32_t channel1, uint32_t channel2)

매개변수 : MCPWMx : 설정할 MCPWM channel0 : MCPWM 채널0 channel1 : MCPWM 채널1 channel2 : MCPWM 채널2

상세설명 MCPWM의 각 채널별로 동작을 시작하게 하는 함수로 매개변수 MCPWMx의 설정 값은

MCPWM이 유일하며, channel0, channel1, channel2는 MCPWM의 채널 0~2에 해당한다. 각 채널의 매개변수를 ENABLE로 설정하면 해당 채널의 동작이 시작되며 DISABLE로 설정하면 해당 채널은 동작하지 않는다.

반환 값 : 없음

Page 6: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

6 345v09

주요 함수와 구조체의 상세 설명 MCPWM_WriteToShadow() : 주기, 펄스 폭 값을 변경된 값으로 갱신한다. 함수원형 : void MCPWM_WriteToShadow (MCPWM_TypeDef *MCPWMx, uint32_t channelNum, MCPWM_CHANNEL_CFG_Type *channelSetup) 매개변수 : MCPWMx: 갱신할 MCPWM channelNum : 갱신할 MCPWM 채널번호 channelSetup : 갱신할 MCPWM 채널의 동작 설정값을 가지고 있는 MCPWM_CHANNEL_CFG_Type 구조체의 포인터 상세설명 MCPWM의 주기, 펄스 폭 값을 변경된 값으로 갱신해주는 함수로

MCPWM_CHANNEL_CFG_Type 구조체의 멤버변수인 PeriodValue와 PulsewidthValue의 값을 변경한 다음 반드시 이 함수를 호출해야만 변경된 값으로 주기와 펄스 폭 값이 갱신된다. 매개변수 MCPWMx의 설정 값은 MCPWM이 유일하며, channelNum은 0~2 중에서 선택하여 갱신할 MCPWM 채널을 선택할 수 있다. channelSetup은 갱신할 MCPWM 채널의 동작 설정값을 가지고 있는 MCPWM_CHANNEL _CFG_Type 구조체의 포인터로 설정한다.

Page 7: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

7 345v09

주요 함수와 구조체의 상세 설명 MCPWM_CHANNEL_CFG_Type : MCPWM의 동작을 설정하는 구조체 구조체선언 : typedef struct { uint32_t channelType; //출력 파형의 정렬 방식을 설정 uint32_t channelPolarity; //출력 핀의 High/Low 신호 극성을 설정 uint32_t channelDeadtimeEnable; //데드타임 기능 사용 여부 설정 uint32_t channelDeadtimeValue; //데드타임 값 uint32_t channelUpdateEnable; //동작 설정 값의 갱신 허용 여부 설정 uint32_t channelTimercounterValue;//MCPWM 타이머 카운터 값 uint32_t channelPeriodValue; //MCPWM의 파형 주기 설정 값 uint32_t channelPulsewidthValue; //MCPWM의 파형 펄스 폭 설정 값 } MCPWM_CHANNEL_CFG_Type; 상세설명 channelType은 출력 파형의 정렬 방식을 설정하는 매개변수이며

MCPWM_CHANNEL_ EDGE_MODE와 MCPWM_CHANNEL_CENTER_MODE중에서 하나로 설정할 수 있다. Edge-Aligned 출력은 MCPWM의 타이머 값이 리셋되어 업카운트로만 동작하고 Center-Aligned 출력은 MCPWM의 타이머 값이 리셋되지 않고 업-다운 카운트 동작을 반복하여 다음 그림과 같이 출력신호에 차이점을 가지고 있다.

Page 8: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

8 345v09

주요 함수와 구조체의 상세 설명 MCPWM_CHANNEL_CFG_Type : MCPWM의 동작을 설정하는 구조체 상세설명

channelPolarity는 MCPWM 출력핀에서 출력되는 신호의 극성을 설정하는 멤버변수로 데드타임 기능 사용시 출력의 상태가 passive와 active로 구분되는데 channelPolarity가 MCPWM_CHANNEL_PASSIVE _LO로 설정되면 passive 상태에서 Low신호가 출력되고 active 상태에서 High 신호가 출력되며 MCPWM_CHANNEL_PASSIVE_HI 로 설정되면 신호가 반전되어 passive상태에서 High 신호가 출력되고 active 상태에서 Low 신호가 출력된다.

Page 9: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

9 345v09

주요 함수와 구조체의 상세 설명 MCPWM_CHANNEL_CFG_Type : MCPWM의 동작을 설정하는 구조체 상세설명 channelDeadtimeEnable은 데드타임 기능의 사용여부를 설정하는 매개변수로

ENABLE로 설정하면 데드타임 기능을 사용하고 DISABLE로 설정하면 사용하지 않는다. 데드타임 기능은 PWM 츨력신호의 상태가 passive(Low/High)에서 active(High/Low)로 바뀔 때 짧은 지연시간을 두어 PWM 출력 A/B가 모두 active(High/Low) 상태가 되는 것을 방지한다. channelDeadtimeValue는 데드타임 값을 설정하는 매개변수로 최대 0x3FF까지 값을 가질 수 있으며 데드타임 카운터는 설정 된 값에서 0까지 다운 카운트로 동작한다. channelUpdateEnable은 MCPWM 채널의 주기와 펄스 폭과 같은 동작 설정 값의 갱신 허용 여부를 설정하는 매개변수로 ENABLE로 설정하면 갱신을 허용하고 DISABLE로 설정하면 허용하지 않는다. channelTimercounterValue는 MCPWM의 타이머/카운터 값으로 MCPWM의 타이머/카운터는 설정된 값에서부터 업카운트로 동작하며 카운트 일치상태의 값은 주기의 설정에 따라 달라진다.

Page 10: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

10 345v09

주요 함수와 구조체의 상세 설명 MCPWM_CHANNEL_CFG_Type : MCPWM의 동작을 설정하는 구조체 상세설명 channelPeriodValue는 MCPWM 출력 파형의 주기 설정 값으로 MCPWM 타이머/카운터의 최대값이 되며 MCPWM 타이머/카운터는 0에서 최대값까지 업카운트 동작을 하거나 최대값에서 0까지 다운카운트 동작을 하므로 이 값에 따라 출력 신호의 주기가 결정된다. channelPulsewidthValue는 MCPWM 츨력 파형의 펄스 폭 설정 값으로 MCPWM 타이머/카운터의 일치 값이 되며 MCPWM 타이머/카운터에서 일치 동작이 발생할 때 출력 신호의 상태가 반전되므로 이 값에 따라 출력 신호의 펄스 폭이 결정된다.

Page 11: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

11 345v09

MCPWM 예제 하드웨어 연결을 아래와 같이 연결 한다.

Page 12: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

12 345v09

MCPWM 예제 관련 회로도 포트1의 28,29번 핀은 MCPWM의 2번출력채널A/B로 동작하므로 MCPWM 출력을 통해 LED의 밝기를 조절할 수 있다.

Page 13: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

13 345v09

MCPWM 예제1 MCPWM 예제1 과제 설명 MCPWM을 이용한 LED 밝기제어 예제 1은 MCPWM의 출력 듀티비를 조절하여 포트 1의 28, 29번 핀에 연결된 LED 1,

2번의 밝기를 제어하는 동작을 한다. 듀티비가 0에서 100으로 증가했다가 다시 100에서 0으로 감소하는 동작을 반복하므로 1번 LED의 밝기가 MCPWM의 출력 듀티비에 따라 달라지게 되며, 2번 LED는 MCPWM의 반전된 신호가 출력되는 핀이므로 1번 LED와 반전된 상태로 밝기가 달라진다.

Page 14: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

14 345v09

MCPWM 예제1 MCPWM 예제1 프로젝트 파일 열기

Page 15: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

15 345v09

MCPWM 예제1 코드 입력

Page 16: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

16 345v09

MCPWM 예제1 분석 헤더 파일 GPIO 드라이버 라이브러리 헤더파일

MCPWM 드라이버 라이브러리 헤더파일

핀 연결 기능 설정 헤더파일

주변장치 사용 설정 헤더파일

#include "lpc17xx_mcpwm.h"

#include "lpc17xx_pinsel.h"

#include "lpc17xx_libcfg.h"

#include "lpc17xx_gpio.h"

Page 17: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

17 345v09

MCPWM 예제1 분석 변수 및 구조체 선언

//MCPWM 채널 설정 구조체

MCPWM_CHANNEL_CFG_Type PWMSetup;

PINSEL_CFG_Type PWMPin[2];

uint32_t PWMValue = 0;

uint32_t PeriodValue = 300;

uint8_t UpDownFlag = 0;

…..

Page 18: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

18 345v09

MCPWM 예제1 분석 Main 함수

…. //포트 1의 28번 핀 설정 PWMPin[0].Portnum = 1; PWMPin[0].Pinnum = 28; PWMPin[0].Funcnum = 1; PWMPin[0].Pinmode = 0; PWMPin[0].OpenDrain = 0; //포트 1의 29번 핀 설정 PWMPin[1].Portnum = 1; PWMPin[1].Pinnum = 29; PWMPin[1].Funcnum = 1; PWMPin[1].Pinmode = 0; PWMPin[1].OpenDrain = 0; PINSEL_ConfigPin(&PWMPin[0]); PINSEL_ConfigPin(&PWMPin[1]);

Page 19: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

19 345v09

MCPWM 예제1 분석 Main 함수

MCPWM_Init(MCPWM); //MCPWM 초기화 //Edge-Aligned 된 PWM 파형을 사용 PWMSetup.channelType = MCPWM_CHANNEL_EDGE_MODE; //Passive 상태에서 Low신호를 출력하도록 설정 PWMSetup.channelPolarity = MCPWM_CHANNEL_PASSIVE_LO; //PWM 데드타임 카운터 사용하지 않음 PWMSetup.channelDeadtimeEnable = DISABLE; //PWM 데드타임 카운터 시간을 0으로 설정 PWMSetup.channelDeadtimeValue = 0; //PWM 펄스 폭 값을 계속해서 변경 PWMSetup.channelUpdateEnable = ENABLE; //MCPWM 타이머/카운터 값을 0으로 초기화 PWMSetup.channelTimercounterValue = 0; //MCPWM의 파형 주기 설정 값 PWMSetup.channelPeriodValue = PeriodValue; //MCPWM의 파형 펄스 폭 설정 값 PWMSetup.channelPulsewidthValue = PWMValue;

Page 20: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

20 345v09

MCPWM 예제1 분석 Main 함수

//MCPWM의 2번 채널에 PWMSetup 구조체의 설정 MCPWM_ConfigChannel(MCPWM, 2, &PWMSetup); //MCPWM의 동작을 시작 MCPWM_Start(MCPWM, DISABLE, DISABLE, ENABLE); ….

Page 21: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

21 345v09

MCPWM 예제1 분석 MCPWM 예제1 프로그램 설명

1)이 프로그램은 4개의 헤더파일을 포함하고 있는데 각 헤더파일의 역할은 다음과 같다. - lpc17xx_gpio.h : GPIO 드라이버 라이브러리 헤더파일 - lpc17xx_mcpwm.h : MCPWM 드라이버 라이브러리 헤더파일 - lpc17xx_pinsel.h : 핀 연결 기능 설정 헤더파일 -lpc17xx_libcfg.h : 주변장치 사용 설정 헤더파일

-2) 헤더파일을 포함한 다음에는 MCPWM 채널 설정 구조체 PWMSetup과 포트1의 28, 29번 핀을 MCPWM의 출력으로 동작하도록 설정하기 위한 핀 연결 기능 설정 구조체 PWMPin을 정의하고, MCPWM의 펄스폭 변조 값을 저장할 PWMValue, 주기 값을 저장할 PeriodValue 변수를 선언하고 주기는 300으로 초기화한다. UpDownFlag 변수는 펄스폭의 증가/감소를 판단하기 위한 플래그 변수이며, 다음으로는 시간 지연을 위한 delay 함수를 정의한다.

발표자
프레젠테이션 노트
void GPIO_SetValue ( uint8_t portNum, uint32_t bitValue) 매개변수 : portNum : GPIO포트 번호 bitValue : 설정될 비트
Page 22: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

22 345v09

MCPWM 예제1 분석 MCPWM 예제1 프로그램 설명

3) 메인 함수에서는 먼저 SystemInit() 함수를 사용하여 LP1768보드에서 사용하고 있는 12㎒ 외부 크리스탈을 시스템 클록으로 사용하도록 설정한다. 동작 클록을 설정한 다음 GPIO_SetDir() 함수를 이용하여 포트 1의 28, 29번 핀을 제외한 6개의 LED가 연결되어 있는 해당 핀을 출력으로 설정하고 GPIO_ClearValue() 함수를 이용하여 GPIO포트를 클리어 하여 LED가 꺼지도록 설정한다. 4) 포트 1의 28번핀을 MCPWM 2번 채널의 출력인 MCOA2로 동작하도록 설정하기 위해 PWMPin[0] 구조체의 멤버 변수인 Portnum은 1로, Pinnum은 28로 설정하고, Funcnum은 1로 설정한다. Pinmode와 OpenDrain은 사용하지 않으므로 0으로 설정한다. 포트 1의 29번핀은 MCPWM 2번 채널의 반전 출력인 MCOB2로 동작하도록 설정하기 위해 PWMPin[1] 구조체의 멤버 변수인 Pornum은 1로, Pinnum은 29로 설정하고, Funcnum은 1로 설정한다. Pinmode와 OpenDrain은 사용하지 않으므로 0으로 설정한다. 5) 각 구조체의 값을 모두 설정한 다음 PINSEL_ConfigPin() 함수에 PWMPin[0]과 PWMPin[1]의 포인터를 매개변수로 사용하여 핀 연결 기능 설정 구조체의 설정 값을 적용시킨다.

발표자
프레젠테이션 노트
void GPIO_SetValue ( uint8_t portNum, uint32_t bitValue) 매개변수 : portNum : GPIO포트 번호 bitValue : 설정될 비트
Page 23: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

23 345v09

MCPWM 예제1 분석 MCPWM 예제1 프로그램 설명

6) 다음으로 MCPWM을 사용하기 위해 먼저 MCPWM_Init()함수로 MCPWM을 초기화 시키고 PWM 출력 채널 설정을 위해 PWMSetup 구조체의 멤버 변수에 설정 값을 입력한다. PWMSetup의 멤버변수 channelType은 MCPWM_CHANNEL_EDGE_MODE로 설정하여 Edge-Aligned 된 PWM 파형을 사용하며, channelPolarity는 MCPWM_CHANNEL_PASSIVE_LO로 설정하여 Passive 상태에서 Low신호를 출력하도록 설정한다. PWM 데드타임 카운터는 사용하지 않으므로 channelDeadtimeEnable은 DISABLE로 설정하고 channelDeadtime Value값은 0으로 설정한다. channelUpdateEnable은 PWM 펄스 폭 값을 계속해서 변경해야 하므로 ENABLE로 설정한다. channelTimer counterValue는 0으로 설정하여 MCPWM 타이머/카운터 값을 0으로 초기화한다. channelPeriodValue는 PeriodValue 변수의 값을 사용하도록 설정하고 channelPulsewidthValue는 PWMValue 변수의 값을 사용하도록 설정한다. 7) MCPWM_ConfigChannel()함수에 MCPWM, 2, PWMSetup 포인터를 매개변수로 사용하여 MCPWM의 2번 채널에 PWMSetup 구조체의 설정사항을 반영하여 MCPWM의 동작을 설정한다. MCPWM의 설정을 모두 완료한 다음 MCPWM_Start()함수를 이용하여 MCPWM의 동작을 시작한다. MCPWM 채널 2번은 4번째 매개변수와 대응되므로 4번째 매개변수를 ENABLE로 하여 MCPWM 2번 채널의 동작을 시작한다.

발표자
프레젠테이션 노트
void GPIO_SetValue ( uint8_t portNum, uint32_t bitValue) 매개변수 : portNum : GPIO포트 번호 bitValue : 설정될 비트
Page 24: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

24 345v09

MCPWM 예제1 분석 MCPWM 예제1 프로그램 설명

8)초기에 UpDownFlag 변수의 값은 0이므로 PWMValue는 0에서 PeriodValue까지 증가하여 0%에서 100%까지 듀티비가 증가하게 되며 PWMValue와 PeriodValue가 같아지면 UpDownFlag 변수의 값을 1로 변경하여 PWMValue가 0까지 감소하도록 설정하며 듀티비 역시 100%에서 0%까지 감소하게 되어 MCPWM 출력핀에 연결된 LED의 밝기가 달라지게 된다. 9) PWMSetup 구조체의 멤버변수 channelPulseWidthValue의 값을 변경한 다음에는 반드시 MCPWM_WriteToShadow()함수를 이용하여 변경된 값을 갱신시켜 주어야 한다는 점에 주의한다.

발표자
프레젠테이션 노트
void GPIO_SetValue ( uint8_t portNum, uint32_t bitValue) 매개변수 : portNum : GPIO포트 번호 bitValue : 설정될 비트
Page 25: LPC1768 Cortex-M3 MCPWMael.chungbuk.ac.kr/lectures/undergraduate/임베디드SW... · 2018. 10. 4. · 345v09 2 개요 특징 The Motor Control PWM (MCPWM) is optimized for threephase

25

LPC1768 Cortex-M3 MCPWM