找回密码
 立即注册
楼主: ulvtkb126

刚刚申请到AI8051U 放到51板上用不了 请指教

[复制链接]
  • 打卡等级:常住居民III
  • 打卡总天数:174
  • 最近打卡:2025-03-18 07:53:51

1

主题

53

回帖

809

积分

高级会员

积分
809
发表于 2024-9-14 10:19:58 | 显示全部楼层
速度不一样,延时定时都得更新一下
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:初来乍到
  • 打卡总天数:6
  • 最近打卡:2025-05-09 14:06:13

5

主题

186

回帖

1405

积分

金牌会员

积分
1405
发表于 2024-9-14 10:33:00 | 显示全部楼层
大*** 发表于 2024-9-12 09:38
1、不知道改了“IO口配置”,是只改了IO的端口号,还是也补上了IO口的工作模式。
因为89c52的IO口只有双向 ...
Especially in 8-bit mode, programs that can be used on STC8051U may not work properly when put into Ai8051U.

?
I thought the initial STC8051U was simply renamed to Ai8051u.
Is it really a different die ?

点评

Dont know actual reason, just according to the using fact. LCD12864, OLED or TFT drived on simulate SPI for instance, they can be displayed correctly on STC8051U, but incorrectly on Ai8051U, with s  详情 回复 发表于 2024-9-14 11:33
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:初来乍到
  • 打卡总天数:7
  • 最近打卡:2025-06-09 10:19:44

18

主题

91

回帖

784

积分

高级会员

积分
784
发表于 2024-9-14 11:26:28 | 显示全部楼层
ulvtk*** 发表于 2024-9-14 08:40
#include"temp.h"
/*******************************************************************************
...

       DSPORT = 0;                         //将总线拉低480us~960us
        i = 70;      
        while(i--);//延时642us
        DSPORT = 1;                        //然后拉高总线,如果DS18B20做出反应会将在15us~60us后总线拉低
这个肯定不够 642微秒,要么你改 定时器延时,要么拿示波器慢慢调吧,18B20,差一点都不行,先不管18B20,假装一个温度,把其他的调完先.
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家II
  • 打卡总天数:435
  • 最近打卡:2025-06-17 05:33:44

28

主题

338

回帖

2800

积分

荣誉版主

积分
2800
发表于 2024-9-14 11:33:58 | 显示全部楼层
本帖最后由 大明狐 于 2024-9-14 12:09 编辑
jm*** 发表于 2024-9-14 10:33
?
I thought the initial STC8051U was simply renamed to Ai8051u.
Is it really a different die ?

Dont  know actual reason, just according to the using fact.{:5_335:}
LCD12864 on parallel driver, OLED or TFT drived on simulate SPI  for instance, under 8-bit mode, above 35MHz frequency,
they can be displayed correctly on STC8051U,
but incorrectly on Ai8051U, with same program, and same download parameters,
Those Displays were showing funny characters, wrong lines or wrong colors, even no light,
unless adding some small delay time in spi drivers,  2 nops at least, then becoming correct.

However, the Ai8051U chip I'm using was on the learningbox v1.2, but the STC8051U chip was on the  different board.
So, right now, I'm not sure what actaully reason caused the diffrent speed above. Maybe some diffrents in the chips, maybe other something on board caused it.



能体会到发现一个不理解的现象然后找原因然后要么解决掉问题要么被问题解决掉的那种快乐是我的幸运
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家II
  • 打卡总天数:466
  • 最近打卡:2025-06-16 09:07:17

17

主题

533

回帖

1398

积分

金牌会员

积分
1398
发表于 2024-9-14 13:47:35 | 显示全部楼层
应该没问题吧? 我的老51 开发版都能用
自信就会温和,温和就会坚定!
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家I
  • 打卡总天数:313
  • 最近打卡:2025-06-17 08:05:24

26

主题

162

回帖

433

积分

中级会员

积分
433
发表于 2024-9-14 13:54:39 | 显示全部楼层
嵌入*** 发表于 2024-9-14 13:47
应该没问题吧? 我的老51 开发版都能用

不知道啊就是用不了  是不是速度不一样啊   延时要改一下
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家II
  • 打卡总天数:468
  • 最近打卡:2025-06-17 06:26:47
已绑定手机

19

主题

3231

回帖

5285

积分

论坛元老

积分
5285
发表于 2024-9-14 14:30:28 | 显示全部楼层
反正我89c52换8051U很正常
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家II
  • 打卡总天数:569
  • 最近打卡:2025-06-18 00:24:58

11

主题

1196

回帖

5536

积分

论坛元老

积分
5536
发表于 2024-9-14 15:31:44 | 显示全部楼层
ulvtk*** 发表于 2024-9-14 13:54
不知道啊就是用不了  是不是速度不一样啊   延时要改一下

延时要改。已经帮你改了。

IMG_20240914_121946.jpg



/**************************************************************************************
*                              DS18B20温度传感器实验                                                                                                  *
实现现象:下载程序后,在温度传感器接口处,按照丝印方向插好温度传感器,数码管就会显示
                        检测的温度值,
注意事项:                                                                                                                                                                  
***************************************************************************************/


#include "STC8051U.h"                         //此文件中定义了单片机的一些特殊功能寄存器
//#include "reg52.h"                         //此文件中定义了单片机的一些特殊功能寄存器
#include"temp.h"       

typedef unsigned int u16;          //对数据类型进行声明定义
typedef unsigned char u8;

sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;


char num=0;
u8 DisplayData[8];
u8 code smgduan[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};

/*******************************************************************************
* 函 数 名         : delay
* 函数功能                   : 延时函数,i=1时,大约延时10us
*******************************************************************************/
void delay(u16 i)
{
        unsigned char data j;
  do {      //延时10us@12.000MHz
        j = 38;
        while (--j);
        }
        while(i--);       
}


/*******************************************************************************
* 函 数 名         : datapros()
* 函数功能                   : 温度读取处理转换函数
* 输    入         : temp
* 输    出         : 无
*******************************************************************************/

void datapros(int temp)          
{
           float tp;  
        if(temp< 0)                                //当温度值为负数
          {
                DisplayData[0] = 0x40;           //   -
                //因为读取的温度是实际温度的补码,所以减1,再取反求出原码
                temp=temp-1;
                temp=~temp;
                tp=temp;
                temp=tp*0.0625*100+0.5;       
                //留两个小数点就*100,+0.5是四舍五入,因为C语言浮点数转换为整型的时候把小数点
                //后面的数自动去掉,不管是否大于0.5,而+0.5之后大于0.5的就是进1了,小于0.5的就
                //算加上0.5,还是在小数点后面。

          }
        else
          {                       
                DisplayData[0] = 0x00;
                tp=temp;//因为数据处理有小数点所以将温度赋给一个浮点型变量
                //如果温度是正的那么,那么正数的原码就是补码它本身
                temp=tp*0.0625*100+0.5;       
                //留两个小数点就*100,+0.5是四舍五入,因为C语言浮点数转换为整型的时候把小数点
                //后面的数自动去掉,不管是否大于0.5,而+0.5之后大于0.5的就是进1了,小于0.5的就
                //算加上0.5,还是在小数点后面。
        }
        DisplayData[1] = smgduan[temp / 10000];
        DisplayData[2] = smgduan[temp % 10000 / 1000];
        DisplayData[3] = smgduan[temp % 1000 / 100] | 0x80;
        DisplayData[4] = smgduan[temp % 100 / 10];
        DisplayData[5] = smgduan[temp % 10];
}


/*******************************************************************************
* 函数名         :DigDisplay()
* 函数功能                 :数码管显示函数
* 输入           : 无
* 输出                  : 无
*******************************************************************************/
void DigDisplay()
{
        u8 i;
        for(i=0;i<6;i++)
        {
                switch(i)         //位选,选择点亮的数码管,
                {
                        case(0):
                                LSA=0;LSB=0;LSC=0; break;//显示第0位
                        case(1):
                                LSA=1;LSB=0;LSC=0; break;//显示第1位
                        case(2):
                                LSA=0;LSB=1;LSC=0; break;//显示第2位
                        case(3):
                                LSA=1;LSB=1;LSC=0; break;//显示第3位
                        case(4):
                                LSA=0;LSB=0;LSC=1; break;//显示第4位
                        case(5):
                                LSA=1;LSB=0;LSC=1; break;//显示第5位       
                }
                P0=DisplayData[5-i];//发送数据
                delay(100); //间隔一段时间扫描       
                P0=0x00;//消隐
        }               
}

/*******************************************************************************
* 函 数 名       : main
* 函数功能                 : 主函数
* 输    入       : 无
* 输    出             : 无
*******************************************************************************/
void main()
{       
        P0M0 = 0x00;
    P0M1 = 0x00;
    P1M0 = 0x00;
    P1M1 = 0x00;
    P2M0 = 0x00;
    P2M1 = 0x00;
    P3M0 = 0x00;
    P3M1 = 0x00;
    P4M0 = 0x00;
    P4M1 = 0x00;
    P5M0 = 0x00;
    P5M1 = 0x00;       
        while(1)
        {
                datapros(Ds18b20ReadTemp());         //数据处理函数
                DigDisplay();//数码管显示函数               
        }               
}



#ifndef __TEMP_H_
#define __TEMP_H_

#include "STC8051U.h"                         //此文件中定义了单片机的一些特殊功能寄存器
//#include<reg52.h>
#include "intrins.h"
//---重定义关键词---//
#ifndef uchar
#define uchar unsigned char
#endif

#ifndef uint
#define uint unsigned int
#endif

//--定义使用的IO口--//
sbit DSPORT=P3^7;

//--声明全局函数--//
void Delay1ms(uint );
uchar Ds18b20Init();
void Ds18b20WriteByte(uchar com);
uchar Ds18b20ReadByte();
void  Ds18b20ChangTemp();
void  Ds18b20ReadTempCom();
int Ds18b20ReadTemp();

#endif



#include"temp.h"
/*******************************************************************************
* 函 数 名         : Delay1ms
* 函数功能                   : 延时函数
* 输    入         : 无
* 输    出         : 无
*******************************************************************************/

void Delay1ms(uint y)
{
                unsigned char data i, j;
        do               //1ms@12.000MHz
        {
        i = 16;
        j = 147;
        do
        {
                while (--j);
        } while (--i);
        } while (--y);       
//        uint x;
//        for( ; y>0; y--)
//        {
//                for(x=110; x>0; x--);
//        }
}
void Delay642us(void)        //@12.000MHz
{
        unsigned char data i, j;

        i = 10;
        j = 255;
        do
        {
                while (--j);
        } while (--i);
}
void Delay68us(void)        //@12.000MHz
{
        unsigned char data i, j;

        _nop_();
        i = 2;
        j = 12;
        do
        {
                while (--j);
        } while (--i);
}

//void Delay6us(void)        //@12.000MHz
//{
//        unsigned char data i;

//        i = 22;
//        while (--i);
//}

/*******************************************************************************
* 函 数 名         : Ds18b20Init
* 函数功能                   : 初始化
* 输    入         : 无
* 输    出         : 初始化成功返回1,失败返回0
*******************************************************************************/

uchar Ds18b20Init()
{
        uchar i;
        DSPORT = 0;                         //将总线拉低480us~960us
        i = 70;       
//        while(i--);//延时642us
        Delay642us();
        DSPORT = 1;                        //然后拉高总线,如果DS18B20做出反应会将在15us~60us后总线拉低
        i = 0;
        while(DSPORT)        //等待DS18B20拉低总线
        {
                Delay1ms(1);
                i++;
                if(i>5)//等待>5MS
                {
                        return 0;//初始化失败
                }
       
        }
        return 1;//初始化成功
}

/*******************************************************************************
* 函 数 名         : Ds18b20WriteByte
* 函数功能                   : 向18B20写入一个字节
* 输    入         : 无
* 输    出         : 无
*******************************************************************************/

void Ds18b20WriteByte(uchar dat)
{
        uint i, j;

        for(j=0; j<8; j++)
        {
                DSPORT = 0;                       //每写入一位数据之前先把总线拉低1us
                i++;
                DSPORT = dat & 0x01;  //然后写入一个数据,从最低位开始
                i=6;
//                while(i--); //延时68us,持续时间最少60us
                Delay68us();
                DSPORT = 1;        //然后释放总线,至少1us给总线恢复时间才能接着写入第二个数值
                dat >>= 1;
        }
}
/*******************************************************************************
* 函 数 名         : Ds18b20ReadByte
* 函数功能                   : 读取一个字节
* 输    入         : 无
* 输    出         : 无
*******************************************************************************/


uchar Ds18b20ReadByte()
{
        uchar byte, bi;
        uint i, j;       
        for(j=8; j>0; j--)
        {
                DSPORT = 0;//先将总线拉低1us
                i++;
                DSPORT = 1;//然后释放总线
//                i++;
//                i++;//延时6us等待数据稳定
                i = 22;
          while (--i);
                bi = DSPORT;         //读取数据,从最低位开始读取
                /*将byte左移一位,然后与上右移7位后的bi,注意移动之后移掉那位补0。*/
                byte = (byte >> 1) | (bi << 7);                                                  
                i = 190;                //读取完之后等待48us再接着读取下一个数
                while(i--);
        }                               
        return byte;
}
/*******************************************************************************
* 函 数 名         : Ds18b20ChangTemp
* 函数功能                   : 让18b20开始转换温度
* 输    入         : 无
* 输    出         : 无
*******************************************************************************/

void  Ds18b20ChangTemp()
{
        Ds18b20Init();
        Delay1ms(1);
        Ds18b20WriteByte(0xcc);                //跳过ROM操作命令                 
        Ds18b20WriteByte(0x44);            //温度转换命令
        //Delay1ms(100);        //等待转换成功,而如果你是一直刷着的话,就不用这个延时了
   
}
/*******************************************************************************
* 函 数 名         : Ds18b20ReadTempCom
* 函数功能                   : 发送读取温度命令
* 输    入         : 无
* 输    出         : 无
*******************************************************************************/

void  Ds18b20ReadTempCom()
{       

        Ds18b20Init();
        Delay1ms(1);
        Ds18b20WriteByte(0xcc);         //跳过ROM操作命令
        Ds18b20WriteByte(0xbe);         //发送读取温度命令
}
/*******************************************************************************
* 函 数 名         : Ds18b20ReadTemp
* 函数功能                   : 读取温度
* 输    入         : 无
* 输    出         : 无
*******************************************************************************/

int Ds18b20ReadTemp()
{
        int temp = 0;
        uchar tmh, tml;
        Ds18b20ChangTemp();                                 //先写入转换命令
        Ds18b20ReadTempCom();                        //然后等待转换完后发送读取温度命令
        tml = Ds18b20ReadByte();                //读取温度值共16位,先读低字节
        tmh = Ds18b20ReadByte();                //再读高字节
        temp = tmh;
        temp <<= 8;
        temp |= tml;
        return temp;
}







回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家I
  • 打卡总天数:313
  • 最近打卡:2025-06-17 08:05:24

26

主题

162

回帖

433

积分

中级会员

积分
433
发表于 2024-9-14 16:13:30 | 显示全部楼层
so*** 发表于 2024-9-14 14:30
反正我89c52换8051U很正常

我好像找到问了
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家I
  • 打卡总天数:313
  • 最近打卡:2025-06-17 08:05:24

26

主题

162

回帖

433

积分

中级会员

积分
433
发表于 2024-9-14 16:15:19 | 显示全部楼层
angm*** 发表于 2024-9-14 15:31
延时要改。已经帮你改了。

谢谢大佬  我想也是只有这个地方有问题
回复 支持 反对

使用道具 举报 送花

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|深圳国芯人工智能有限公司 ( 粤ICP备2022108929号-2 )

GMT+8, 2025-6-18 00:26 , Processed in 0.166807 second(s), 115 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表