找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 6845|回复: 3
打印 上一主题 下一主题
收起左侧

Keil编译错误

[复制链接]
跳转到指定楼层
楼主
ID:6974 发表于 2008-11-21 11:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

#include <stdio.h>
#include <absacc.h>
#include <reg52.h>
#include <math.h>
#define uchar unsigned char
#define uint unsigned int 

//*?????
sbit E0=P3^0;      //*??P3.0,?EPWM??????
sbit L0=P2^4;
sbit K2=P2^2;
sbit K1=P2^1;
sbit K0=P2^0;

//*????????"0"-"5"
uchar code a[6]={0x11,0x12,0x13,0x14,0x15,0x16};
//*IPWM????
uchar code  b[6]={0x0c,0x19,0xab,0x32,0x3f,0x4f}; 
uchar time;
uchar period[6]={6000,5938,5875,5813,5750,5688};
uchar high[6]={250,312,375,437,500,562};
int i;

timer0 () interrupt 1 using 1
{
 TH0=(65536-6250)/256;
 TL0=(65536-6250)%256;
 if (++time==high[i])E0=0;
 else if(time==period[i])
 {time=0;
  E0=1;
 }
}


//*?????
void delay(void)
{
   int j;
  for(j=300;j>0;j--);
}
 
main()
{
 
  TMOD=0X01;
  TH0=(65536-6250)/256;
  TL0=(65536-6250)%256;
  EA=1;
  ET0=1;
  TR0=1;
   i=5;
   E0=1;            //* ?????
   K0=1;
   K1=1;
   K2=0;
   P0=0;    
   P1=0x10;

   delay();
   if ((K1==0)&&(K2==1))
  {i++;
         time=period[i];time++;
        time=high[i];
        P0= b[i];
        P1= a[i]; }
   else if ((K2==0)&&(K1==1))
    {
     i--; 
        time=period[i]; time++;
        time=high[i];
        P0= b[i];
        P1= a[i];
        }
      
   if ((K1==0)&&(i<=0))
         { i=0;
        time=period[i];time++;
        time=high[i];
        P0= b[i];
        P1= a[i];
        }
       if ((K2==0)&&(i>=5))
      {
   i=5;
         time=period[i];time++;
        time=high[i];
        P0= b[i];
        P1= a[i];
         }     
}



模拟出现  *** error 65: access violation at C:0x0100 : no 'execute/read' permission  方面的错误

谁可以帮解决下 然后告诉我相关方法 让我学习下   cmm_1@163.com  QQ:78636072( 晚上在)
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶1 踩
回复

使用道具 举报

沙发
ID:6974 发表于 2008-11-21 11:21 | 只看该作者
*** error 65: access violation at C:0x0100 : no 'execute/read' permission
 
i=2  时候的错误
回复

使用道具 举报

板凳
ID:6974 发表于 2008-11-21 11:41 | 只看该作者

 

i=1  wu cuo
i=2 /*** error 65: access violation at C:0x0100 : no 'execute/read' permission
i=3 /*** error 65: access violation at C:0x0200 : no 'execute/read' permission
i=4 /*** error 65: access violation at C:0x0200 : no 'execute/read' permission
i=5 /*** error 65: access violation at C:0x0400 : no 'execute/read' permission
i=6 /*** error 65: access violation at C:0x0500 : no 'execute/read' permission

回复

使用道具 举报

地板
ID:883242 发表于 2021-6-25 21:12 | 只看该作者
不知道你的65行是哪一行,先说说隐含的另一个错误,编译时不会出错,但是运行时会出严重问题。
if (++time==high[i])E0=0;
else if(time==period[i])
中断里面这两个[i]操作是有问题的。

51是8位机,i是16位的,i赋值,i++,i--都是分多步处理的,如i=255,i++是这么操作的:
i=0;CY=1;
i=256;
可见如果在两次执行中间发生中断,那么中断里面的[i]操作的i是一个严重错误的值,程序的行为会发生异常。
所以主函数里面操作i之前要关中断,操作完再开中断!

这就叫“原子操作”!
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

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