最新三星单片机应用

IAR汇编和C混合编程示例

发布时间:2010.10.13 新闻来源:展亨科技(香港)有限公司/深圳市展亨隆电子有限公司 浏览次数:
//IAR汇编和C混合初步
//dami 2006 10,3
#include
#include "intrinsics.h"//包含内部函数
#define uchar unsigned char
#define uint unsigned int
#definetestbit(var,bit)((var)&(1<<(bit)))//位测试
#definesetbit(var,bit)((var)|=(1<<(bit)))//位置1
#defineclrbit(var,bit)((var)&=~(1<<(bit)))//位清零 clrbit(p3,1);就是了
__code const volatile uchar Smart_Value[4] @0x003c = {0xff,0xff,0xbb,0xfd};//cpu芯片配置 3.3V
void delay();
void fhu1(void);
uchar Buffer=0;
void main()
{
    __no_operation();
  __no_operation();
  WDTCON = 0xaa;//禁止看门狗
  BTCON = 0x0b;//清除BT计数值,及时钟频率分频。f=fosc/128
  CLKCON = 0x18;//fcpu=fosc/1,在掉电模式下允许中断唤醒主/副晶振
  SYM &= 0xf8;//选择零页
  OSCCON = 0x04;//选择主晶振作系统时钟,禁止副时钟
  STPCON = 0x00;//禁止STOP指令,0xa5为enable STOP instruction
  VLDCON = 0x5d;
   
  WTCON = 0x00;//
  FLAGS = 0x00;// clear flags
   
  P0PUR = 0x00;
  P1PUR = 0x00;
  P0CONH = 0x0a;//p0.5,p0.4推拉输出
  P0CONL = 0x2a;//p0.0,p0.1,p0.2推拉输出,P0.3输入****
  P1CONH = 0xff;//LCD com0--com3信号
  P1CONL = 0xf2;//p1.0为输入,p1.1为推拉输出,p1.2,p1.3为AD输入
  P2CONH = 0xff;//seg信号
  P2CONL = 0xff;//seg信号
  P3CONH = 0xaa;//p3.1输入.p3.0为seg,其余为推拉输出
  P3CONL = 0x4b;
  P3INT = 0x00;//禁止p3引脚中断
  P3PND = 0x00;
  P4CONH = 0xff;//seg
  P4CONL = 0xff;
   
  P0 = 0x00;
  P1 = 0x00;
  P2 = 0x00;
  P4 = 0x00;
   
  Buffer = Smart_Value[0];
  __disable_interrupt();
    if(testbit(P0,3)==1)
    {
        fhu1();
        //delay();
        clrbit(P3,1);
        while(!testbit(P0,3));
    }
    while(1);
}
void delay()
{
  unsigned int i;
  for (i=1000;i>0;i--);
}

//以下是汇编文件
public fhu1
extern P3
MODULE fhu1
PUBLIC fhu1
RSEG CODE:CODE:NOROOT(0)
//**********************
fhu1:
     
     
u0: ld P3,#55H
    nop
    nop
    ret
//***********************
ENDMOD
end
单片机开发工具
单片机编程器
ARM开发工具
C编译器
联系方式
三星单片机:

ic168@zh-ic.COM

开发工具:

B6078S@163.com

网站相关建议:

zh-ic@163.com

客户服务
 MSN咨询