CH552/projects/examples/PWM/Main.C

56 lines
2.4 KiB
C++
Raw Normal View History

2018-10-17 10:44:45 +02:00
/********************************** (C) COPYRIGHT *******************************
* File Name : Main.C
* Author : WCH
* Version : V1.0
* Date : 2017/01/20
* Description : CH554 PWM<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>ձ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>PWMĬ<EFBFBD>ϵ<EFBFBD>ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
֧<EFBFBD><EFBFBD><EFBFBD>жϷ<EFBFBD>ʽ<EFBFBD>޸<EFBFBD>PWMռ<EFBFBD>ձ<EFBFBD>
*******************************************************************************/
#include "..\Public\CH554.H"
#include "..\Public\Debug.H"
#include "PWM.H"
#include "stdio.h"
#pragma NOAREGS
main( )
{
CfgFsys( ); //CH554ʱ<34><CAB1>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mDelaymS(5); //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD>Ӻ󣬽<D3BA><F3A3ACBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ȶ<EFBFBD>ʱ<EFBFBD><CAB1>
mInitSTDIO( ); //<2F><><EFBFBD><EFBFBD>0<EFBFBD><30>ʼ<EFBFBD><CABC>
printf("start ...\n");
P1_MOD_OC &= ~(bPWM1 | bPWM2); //<2F><><EFBFBD><EFBFBD>PWM<57><4D><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
P1_DIR_PU |= bPWM1 | bPWM2;
SetPWMClk(4); //PWMʱ<4D><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <09><>4<EFBFBD><34>Ƶ
ForceClearPWMFIFO( ); //ǿ<><C7BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PWM FIFO<46><4F>COUNT
CancleClearPWMFIFO( ); //ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PWM FIFO<46><4F>COUNT
PWM1OutEnable( ); //<2F><><EFBFBD><EFBFBD>PWM1<4D><31><EFBFBD><EFBFBD>
PWM2OutEnable( ); //<2F><><EFBFBD><EFBFBD>PWM2<4D><32><EFBFBD><EFBFBD>
PWM1OutPolarHighAct( ); //PWM1<4D><31><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϵͣ<CFB5><CDA3><EFBFBD><EFBFBD><EFBFBD>Ч
PWM2OutPolarLowAct( ); //PWM2<4D><32><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϸߣ<CFB8><DFA3><EFBFBD><EFBFBD><EFBFBD>Ч
#if PWM_INTERRUPT
PWMInterruptEnable();
EA = 1;
SetPWM1Dat(0x10);
SetPWM2Dat(0x40);
while(1);
#endif
SetPWM1Dat(0x10); //ռ<>ձ<EFBFBD>0x10/256
SetPWM2Dat(0x40);
while(1){
if(PWM_CTRL&bPWM_IF_END){
PWM_CTRL |= bPWM_IF_END; //<2F><><EFBFBD><EFBFBD>PWM<57>ж<EFBFBD>
SetPWM1Dat(0x10);
SetPWM2Dat(0x40);
#ifdef DE_PRINTF
printf("PWM_CYC_END %02X\n",(UINT16)PWM_CTRL);
#endif
}
}
}