Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

不同型号单片机兼容 #1

Open
Endragon2003 opened this issue Apr 2, 2022 · 4 comments
Open

不同型号单片机兼容 #1

Endragon2003 opened this issue Apr 2, 2022 · 4 comments

Comments

@Endragon2003
Copy link

你好,我用的是STC89C52,好像没有辅助寄存器,不知道为什么我用常规方法也没法让我的音乐响起来,能不能帮帮忙

@Sheng-12138
Copy link

你好,我用的是STC89C52,好像没有辅助寄存器,不知道为什么我用常规方法也没法让我的音乐响起来,能不能帮帮忙

在up讨论区看到:暂时不支持STC89系列没有定时器时钟输出功能的单片机,auxr是一个辅助寄存器
驱动有源蜂鸣器的话给低电平就可以响,无源蜂鸣器的话要给PWM方波。可以检查一下引脚定义。

@ghost
Copy link

ghost commented Apr 26, 2022

你好,我用的是STC89C52,好像没有辅助寄存器,不知道为什么我用常规方法也没法让我的音乐响起来,能不能帮帮忙

没响是因为定时器溢出信号没有输出到IO

主要是因为STC89这种单片机用中断翻转IO电平太慢了,有些音调一高就跑调,再加上有中断,不同频率的音符持续时间就不准了,嫌麻烦,就用的STC15这种可以直接把定时器输出到IO口的单片机
一定要用STC89系列单片机,可以在定时器中断里面翻转IO:

void tm0_isr() interrupt 1
{
  BEEP = !BEEP;
}

然后main里面加一句:
ET0 = 1;
删除 WAKE_CLKO = 0x01; //enable timer0 clock output 这一行
改延时函数,用STC-ISP重新生成一个适合STC89的
freq2timer.py
clock改成晶振频率的二倍
下载时不能选2T模式(好像叫这个)
理论上这样就行了,肯定能出声

@Lee52
Copy link

Lee52 commented Jun 8, 2022

厉害了,我试一下,我也是STC89C52

@Lee52
Copy link

Lee52 commented Jun 8, 2022

STC89C52按你的方法试了下,不成功,不出声

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants