3450 views|6 replies

47

Posts

0

Resources
The OP
 

About the PWM output configuration program of the Hetai HT66F018 chip [Copy link]

Does anyone have C code for PWM output configuration of HT66F018 chip?

Latest reply

This is the code I used in 0185. I was too lazy to delete the delay program.   Details Published on 2021-6-29 15:42
 
 

9702

Posts

24

Resources
2
 

Isn't it provided in the official routine?

 
 
 

23

Posts

0

Resources
3
 

Generating PWM using a timer

#include "HT66F018.h"

#define u8 unsigned char
#define u16 unsigned int

#define BEEP _t1on //TMn counter On/Off control bit

void delay_ms(u16 ms)
{
while(ms--)
{
GCC_DELAY(2000); //The compiler comes with a delay of a specified period. At the main frequency of 8Mhz, one instruction cycle is 0.5us
GCC_CLRWDT();
}
}


void pwminit()
{
_pac7=0;
_pa7=0;
_t1cp=1;//Set the port to timer port

_tm1c0=0x20;//clk=sys/16
_tm1c1=0xa8;//pwm mode high level is valid, comparator P match clear 0
_tm1rpl=125;//f=sys/16/125=4k
_tm1rph=0;

_tm1al=62;//duty=62/125=49.6%
_tm1ah=0;
}

void main()
{
_wdtc=0xa8;//turn off watchdog
_pac3=0;//set to output

_cos=1;//set pa3 pin to IO, not comparator output
_acerl=0;//analog port turned off

pwminit();



while(1)
{
BEEP=1;

}

}

Comments

Got it, thanks   Details Published on 2021-6-29 14:06
Got it, thanks   Details Published on 2021-6-29 14:00
 
 
 

47

Posts

0

Resources
4
 
hzz592788 posted on 2021-6-29 08:58 Generate PWM using timer #include "HT66F018.h" #define u8 unsigned char #define u16 unsigned int ...

Got it, thanks

 
 
 

47

Posts

0

Resources
5
 
hzz592788 posted on 2021-6-29 08:58 Generate PWM using timer #include "HT66F018.h" #define u8 unsigned char #define u16 unsigned int ...

Is this program from the Internet? ? The previous delay function seems to be unused, and the following code needs to be verified

Comments

This is the code I used in 0185. I was too lazy to delete the delay program.  Details Published on 2021-6-29 15:42
 
 
 

23

Posts

0

Resources
6
 
xuanyuanzhu posted on 2021-6-29 14:06 Is this program from the Internet? ? The previous delay function does not seem to be used, and the following code needs to be verified

This is the code I used in 0185. I was too lazy to delete the delay program.

Comments

Thanks, follow your code and read the manual  Details Published on 2021-6-29 15:55
 
 
 

47

Posts

0

Resources
7
 
hzz592788 posted on 2021-6-29 15:42 This is the code I used in 0185. I was too lazy to delete the delay program

Thanks, follow your code and read the manual

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list