01/01/2012

2012 Happy New Year~!

By dch1 in Just Notes No Comments

2012年~世界末日到来了,附上几张ANDROID 4.0.2的截图共勉吧,末日系统。。。。。

25/10/2011

Steve Jobs Biography

By dch1 in Just Notes No Comments Tags: Steve Jobs

20111025-162229.jpg

乔布斯的授权传记昨天发行了,抢先下载到了电子版本,开始阅读中。

19/10/2011

Graduation Ceremony for Yao

By dch1 in Just Notes No Comments

image

10/10/2011

Final Thesis

By dch1 in Just Notes No Comments

毕业论文提交了,总共完成102页,共计14,000字

 

 

今天阵雨多,不过下午出彩虹了…

image

There are TWO MORE task to go…..

01/10/2011

Assignments

By dch1 in Just Notes No Comments

image

最近作业比较多,最强人所难的就是那篇商业报告,本来学工科就是为了逃避商科,现在就在为这个头疼。
除此之外,毕业论文也是重点项目之一,等待这个写完了立马转战毕业论文。

18/09/2011

Keil C51 仿真问题解决

By dch1 in Just Notes, Life No Comments

今日用SST的51仿真芯片测试程序,谁知在一次意外断电的途中,单片机无法再与Keil软件通讯,换原来的STC芯片刷写照常,证明问题出在仿真芯片上。

网上搜索后了解到,可能是断电导致监控程序FLASH区域数据丢失,需要重写程序,于是到网上找到了V4.5的监控程序,但用SP200S专业版始终无法写入芯片。

再次查询网站后,找到如下一篇帖子:http://www.willar.com/forum/forum_view.asp?view_id=16752

但解决方案仍然没有。

其实解决方法很简单,在烧写SST仿真固件之前,重新插拔一次编程器,一切迎刃而解。


另外提供仿真固件下载:http://www.mcusj.com/forum/forum_view.asp?forum_id=29&view_id=16829

 

04/09/2011

C51 Programming Cont.

By dch1 in Just Notes No Comments

今天终于学习了一直以来想学的中断功能,也是单片机中三大核心之一(定时器、中断、串口通信)

还是挺好玩的,下面还是一些课后习题:

1、利用定时/计数器T0从P1.0输出周期为1s的方波,让发光二极管以1HZ闪烁,设晶振频率为12MHz。

#include <reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
void delay1s(void);

uchar xdata status,i;

void main()
{
 TMOD=0x01;
 TH0=(65536-50000)/256;
 TL0=(65536-50000)%256;
 EA=1;
 ET0=1;
 TR0=1;
 while(1)
 {
  for (status=0; status<20; i++)
  P0=~0x01;
  status=0;
  for (status=0; status<20; i++)
  P0=~0x00;
  status=0;
 }
}

void delay1s(void)
{
    unsigned char a,b,c;
    for(c=95;c>0;c–)
        for(b=26;b>0;b–)
            for(a=185;a>0;a–);
}

void exter0() interrupt 1
{
 TH0=(65536-50000)/256;
 TL0=(65536-50000)%256;
 status++;
}

另外,如果需要定时器1来执行,则需要这么写:

void exter1() interrupt 3
{
 TH1=(65536-50000)/256;
 TL1=(65536-50000)%256;
 status++;
}

main()

 TMOD=0x10;
 TH1=(65536-50000)/256;
 TL1=(65536-50000)%256;
 EA=1;
 ET1=1;
 TR1=1;

2、利用定时/计数器T1产生定时时钟,由P1口控制8个发光二极管,使8个指示灯依次一个一个闪动,闪动频率为10次/秒(8个灯依次亮一遍为一个周期),循环。

#include <reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
void delay1s(void);

uchar xdata status,i,j,t;

void main()
{
 TMOD=0x10;
 TH1=(65536-50000)/256;
 TL1=(65536-50000)%256;
 EA=1;
 ET1=1;
 TR1=1;
 while(1)
 {
  P0=~0x01;
  for (i=0;i<8;i++)
  {
   t=_crol_(P0,1);
   for (status=0;status<2;j++)
   P0=~0x00;
   status=0;
   for (status=0;status<2;j++)
   P0=t;
   status=0;
  }
 }
}

void delay1s(void)
{
    unsigned char a,b,c;
    for(c=95;c>0;c–)
        for(b=26;b>0;b–)
            for(a=185;a>0;a–);
}

void exter1() interrupt 3
{
 TH1=(65536-50000)/256;
 TL1=(65536-50000)%256;
 status++;
}

3、同时用两个定时器控制蜂鸣器发声,定时器0控制频率,定时器1控制同个频率持续的时间,间隔2s依次输出1,10,50,100,200,400,800,1k(hz)的方波。

这道题费的时间比较长,可能是没有完全掌握双定时器优先级的缘故,搞了一晚上,除了这道题,其余三道题基本上都是十几分钟内就搞定的。

PS: 暂时先放弃这道题吧…………

 

4、用定时器以间隔500MS在6位数码管上依次显示0、1、2、3….C、D、E、F,重复。

#include <reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
void delay1s(void);

uchar xdata status,status1;
sbit Lock=P3^6;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void main()
{
 TMOD=0x01;
 TH0=(65536-50000)/256;
 TL0=(65536-50000)%256;
 EA=1;
 ET0=1;
 TR0=1;
 Lock=1;
 while(1)
 {
  P2=~0x01;
  for (status1=0; status1<16; status1++)
  {
   while (status<10);
   status=0;
   Lock=1;
   P0=~table[status1];
   Lock=0;
   P2=_crol_(P2,1);
  }
 }
}

void delay1s(void)
{
    unsigned char a,b,c;
    for(c=95;c>0;c–)
        for(b=26;b>0;b–)
            for(a=185;a>0;a–);
}

void exter0() interrupt 1
{
 TH0=(65536-50000)/256;
 TL0=(65536-50000)%256;
 status++;
}

03/09/2011

C51 Revision

By dch1 in Just Notes No Comments

今天复习跑马灯程序,感觉熟练多了,呵呵,基本上没有按照题目编,因为其实细节就是那些延迟的参数,那个很容易修改的。

Example 1: 8个发光管演示出8位二进制数累加过程。

#include <reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char

void delay1s(void);

uchar status;

void main()
{
 status=0;
 while (1)
 {
  delay1s();
  status=status+1;
  P0=~status;
 }
}

void delay1s(void)
{
    uchar a,b,c;
    for(c=46;c>0;c–)
        for(b=152;b>0;b–)
            for(a=70;a>0;a–);
    _nop_();  //if Keil,require use intrins.h
}

Example 2: 8个发光管来回流动,管亮100ms,[流动时让蜂鸣器发出“滴滴”声。]

#include <reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char

void delay1s(void);

uchar status;

void main()
{
 while (1)
 {
  P0=0xFE;
  delay1s();
  for(status=1; status<8; status++)
  {
   
   P0=_crol_(P0,1);
   delay1s();
  }
  //P0=0x7F;
  for(status=7; status>1; status–)
  {
   
   P0=_cror_(P0,1);
   delay1s();
  }
 }
}

void delay1s(void)
{
    uchar a,b,c;
    for(c=46;c>0;c–)
        for(b=152;b>0;b–)
            for(a=70;a>0;a–);
    _nop_();  //if Keil,require use intrins.h
}

Example 3: 8个发光管间隔200ms由上至下,再由下至上,再重复一次,然后全部熄灭再以300ms间隔全部闪烁5次。重复此过程。

#include <reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char

void delay1s(void);
uchar status,s1;

void main()
{
 while (1)
 {
  P0=0xFE;
  delay1s();
  for(status=1; status<8; status++)
  {
   
   P0=_crol_(P0,1);
   delay1s();
  }
  //P0=0x7F;
  for(status=7; status>0; status–)
  {
   
   P0=_cror_(P0,1);
   delay1s();
  }
  for(status=0; status<5; status++)
  {
   P0=0x00;
   delay1s();
   P0=~P0;
   delay1s();
  }
 }
}

void delay1s(void)
{
    uchar a,b,c;
    for(c=46;c>0;c–)
        for(b=152;b>0;b–)
            for(a=70;a>0;a–);
    _nop_();  //if Keil,require use intrins.h
}

 

26/08/2011

Open Day for Deakin University at Waurn Ponds Campus

By dch1 in Just Notes No Comments

21st of the August is the Open Day for Deakin University. Taken several photos on that day~~ Lovely Day!

09/08/2011

C51 Programming – First Step

By dch1 in Life No Comments

这两天在自学C51编程,跟着教程做了几个最简单的HELLO WORLD程序,也就是跑马灯程序,还是比较有成就感的。

基本上是自己想出来的,个别指令有答案提示。

上图片太麻烦了,搞了半天AVI-GIF,画质还非常差,就先只上一个代码吧

题目要求:

间隔300ms第一次一个管亮流动一次,
第二次两个管亮流动,依次到8个管亮,
然后重复整个过程。

代码:

#include <reg52.h>
#include <intrins.h>
static char High=1;
static char Low=0;
void delay1s();
#define uchar unsigned char
int a;
uchar i,j;
sbit FM=P2^7;
void main()
{
 while (1)
 {
  for (i=0;i<8;i++)
  {
   a=0xff;
   for (j=0;j<=i;j++)
   {
    a=a<<1;
   }
   for (j=0;j<8-i;j++)
   {
    P0=a;
    a=_crol_(a,1);
    delay1s();
   }
  }
 }
}

 
void delay1s(void)
{
    unsigned char a,b,c;
    for(c=95;c>0;c–)
        for(b=26;b>0;b–)
            for(a=185;a>0;a–);
}

«< 10 11 12 13 14 >»
Dominic's Blog
记录成长足迹,拥抱多彩生活
  • Categories
  • Thanks
RSS
© Dominic's Blog 2025