jmg 发表于 2024-9-13 10:30:24

beishen2009 发表于 2024-9-12 08:37
现在可以断定是出在定时器上面 还不知道如何兼容 89c51rd+的 定时器代码 请问有知道的大哥吗 ...

You need to drill into the details.Which timer(s) do you use ?




















beishen2009 发表于 2024-9-13 10:56:30

本帖最后由 beishen2009 于 2024-9-13 10:59 编辑

定时器0工作方式1 啊 大哥 求指教啊

void T0_time() interrupt 1      

main(){



TMOD=0X01;                                                //设置定时器0工作方式1
TH0=(65536-50000)/256;                        //重装值,12MHz定时50ms的数值为50000
TL0=(65536-50000)%256;
EA=1;                                                      //开总中断
ET0=1;
外while(1){}

}

jmg 发表于 2024-9-13 12:29:53

本帖最后由 jmg 于 2024-9-13 12:57 编辑

beishen2009 发表于 2024-9-13 10:56
定时器0工作方式1 啊 大哥 求指教啊

void T0_time() interrupt 1      

What code is inside your T0 interrupt ?
How close is the interrupt to working ?If you have 12MHz SysCLK and the correct /12 prescaler, you should have 50ms ?

I am looking at STC8H series, as that is a more modern choice. Because you need to make small changes anyway, it is best to move to cheapest/newest, at the same time.

You are using mode 01, which should be ok, but there is a better reload mode = 00, that does not need interrupt re loading at all.
STC8H:



Note the reload registers RL_TH0, RL_TL0, need TR0 = 0 to access them, then you set TR0 = 1 after they are loaded.

A quick easy test is to toggle a pin inside the interrupt with simple test code initially.
Note the STC8H has CLKDIV and the STC11F has CLK_DIV that are defined at ISP program time, and the default PORT RESET mode is different.


Addit: If you want the old 8051 pinout, the STC8H will not fit, so the STC11 is better choice. You should define CLK_DIV and RST pin features for STC11

jmg 发表于 2024-9-13 12:58:10

本帖最后由 jmg 于 2024-9-13 13:05 编辑

You should also look at the SFR maps





Note CLK_DIV for SYSCLK and P0M0, P0M1 etc set port behaviors.

I think the default POR values ​​are standrd 8051 BiDirectional port ?

beishen2009 发表于 2024-9-13 20:04:21

谢谢啊我再试试啊
页: 1 2 [3]
查看完整版本: 求教 用 11F60XE 直接替换掉 89C516之后 程序异常不断重启 而且 引脚之间互相