这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 企业专区 » Renesas » blueapple2的进程

共18条 2/2 1 2 跳转至
助工
2012-09-05 19:46:26     打赏
11楼
优酷中有共享链接,粘贴过来就行了。

助工
2012-09-14 12:23:00     打赏
12楼
IAR刚搞好,继续实验

助工
2012-09-14 12:46:24     打赏
13楼
串口实验:


主要代码:

助工
2012-09-20 12:46:19     打赏
14楼
LCD1602实验:


引脚配置:
P7.0: RS
P7.1: RW
P7.2: E
P2 : 数据

代码:
void delay_ms(UINT n)
{
  UINT i;
  for (i=0;i<n;i++)
  {
     TAU0_Channel0_Start();
     do
     {
     }
      while (TimerFlag==0);
      TAU0_Channel0_Stop();
      TimerFlag=0;
  }
}
void LCD_init(void)
{
  LCD_write_command(0x33);
  LCD_write_command(0x0c);
  LCD_write_command(0x06);
  LCD_write_command(0x01);
delay_ms(4);
}
void LCD_write_command(UCHAR command)
{
P2=command;
delay_ms(1);
PORT_ChangeP70Output(0);
delay_ms(1);
PORT_ChangeP71Output(0,0);
delay_ms(1);
PORT_ChangeP72Output(1);
delay_ms(1);
PORT_ChangeP72Output(0);
delay_ms(4);
}
void LCD_write_data(UCHAR dat)
{
P2=dat;
PORT_ChangeP70Output(1);
delay_ms(1);
PORT_ChangeP71Output(0,0);
delay_ms(1);
PORT_ChangeP72Output(1);
delay_ms(1);
PORT_ChangeP72Output(0);
delay_ms(4);
}
void LCD_disp_char(UCHAR x,UCHAR y,UCHAR dat)
{
UCHAR address;
if(y==1)
address=0x80+x;
else if(y==2)
address=0xc0+x;
LCD_write_command(address);
delay_ms(2);
LCD_write_data(dat);
delay_ms(2);
}
void LCD_disp_string(UCHAR x,UCHAR y,UCHAR *s)
{
   UCHAR address;
   if(y==1)
      address=0x80+x;
   else if(y==2)
      address=0xc0+x;
   LCD_write_command(address);
   delay_ms(2);
   while(*s)
   {
      LCD_write_data(*s);
      delay_ms(2);
      s ++;
   }
}

void  main(void)
{
 /* Start user code. Do not edit comment generated here */
         ADPC = _01_ADPC_DI_ON;
        LCD_init();
       LCD_disp_string(0,1,"Renesas @EEPW");
 while (1U)
 {
  ;
 }
 /* End user code. Do not edit comment generated here */
}


助工
2012-09-22 16:16:30     打赏
15楼

为了进行AD实验,对LCD驱动作了改造,用P5.2-P5.5作为LCD的数据传送端口,以便让出P2用作AD输入。
相关函数如下:
void delay_ms(UINT n)
{
  UINT i;
  for (i=0;i<n;i++)
  {
     TAU0_Channel0_Start();
     do
     {
     }
      while (TimerFlag==0);
      TAU0_Channel0_Stop();
      TimerFlag=0;
  }
}
void LCD_init(void)   //初始化LCD
{
  LCD_write_command(0x28);  //4位数据模式
  LCD_write_command(0x0c);  //显示开
 // LCD_write_command(0x06);
  LCD_write_command(0x01);  //清屏
delay_ms(4);
}
void LCD_en_write(void)   //液晶使能
{
    delay_ms(1);
    PORT_ChangeP71Output(0,0);
    delay_ms(1);
    PORT_ChangeP72Output(1);
    delay_ms(1);
    PORT_ChangeP72Output(0);
    delay_ms(4);
}
void LCD_write_command(UCHAR command) //写指令
{
  UCHAR tmp;
  PORT_ChangeP70Output(0); //RS=0
  delay_ms(1);
  tmp  =command;
  tmp &=0xf0;            //取高4位
  tmp  =tmp>>2;           //右移2位
  P5  &=0xc3;              //清
  P5   =tmp;             //写高4位
  LCD_en_write();
  tmp  =command;
  tmp &=0x0f;            //取高4位
  tmp  =tmp<<2;           //左移2位
  P5  &=0xc3;              //清
  P5   =tmp;             //写低4位
  LCD_en_write();
}
void LCD_write_data(UCHAR dat) //写数据
{
  UCHAR tmp;
  PORT_ChangeP70Output(1); //RS=1
  delay_ms(1);
  tmp  =dat;
  tmp &=0xf0;            //取高4位
  tmp  =tmp>>2;           //右移2位
  P5  &=0xc3 ;             //清
  P5   =tmp;             //写高4位
  LCD_en_write();
  tmp  =dat;
  tmp &=0x0f;            //取高4位
  tmp  =tmp<<2;           //左移2位
  P5  &=0xc3;              //清
  P5   =tmp;             //写低4位
  LCD_en_write();
}
void LCD_disp_char(UCHAR x,UCHAR y,UCHAR dat) //显示字符
{
UCHAR address;
if(y==1)
address=0x80+x;
else if(y==2)
address=0xc0+x;
LCD_write_command(address);
delay_ms(2);
LCD_write_data(dat);
delay_ms(2);
}
void LCD_disp_string(UCHAR x,UCHAR y,UCHAR *s)//显示字符串
{
   UCHAR address;
   if(y==1)
      address=0x80+x;
   else if(y==2)
      address=0xc0+x;
   LCD_write_command(address);
   delay_ms(3);
   while(*s)
   {
      LCD_write_data(*s);
      delay_ms(3);
      s ++;
   }
}

主函数:
void  main(void)
{
 /* Start user code. Do not edit comment generated here */
       //  ADPC = _01_ADPC_DI_ON;
        LCD_init();
      //  LCD_disp_char(0,1,0x49);
       // LCD_disp_char(1,1,0x20);
      //  LCD_disp_char(2,1,0x4c);
        //LCD_disp_char(3,1,0x4f);
      //  LCD_disp_char(4,1,0x56);
          LCD_disp_string(0,1,"Renesas @EEPW");
          LCD_disp_string(0,2,"Renesas @EEPW");
 while (1U)
 {
  ;
 }
 /* End user code. Do not edit comment generated here */
}


助工
2012-09-22 16:30:24     打赏
16楼
接着上传图片:

助工
2012-09-27 17:00:35     打赏
17楼
LCD+AD实验:
主函数:
void  main(void)
{
 /* Start user code. Do not edit comment generated here */
        ADPC = _01_ADPC_DI_ON;
        LCD_init();
        AD_ComparatorOn();            /* Enable ADC voltage comparator (ADCE = on) */
        AD_Start();                   /* Start ADC (ADCS = 0n) */
  while (1U)
 {
          if(ADC_done == MD_TRUE)
          {
            AD_Stop();
            ADC_Result=ADC_Result /15;
            ADC_Value=ADC_Result;
            ADC_done  = MD_CLEAR;
            ADC_Value=ADC_Result%10 + 0x30;
            LCD_disp_char(5,1,ADC_Value);
            ADC_Result=ADC_Result/10;
            ADC_Value=ADC_Result%10 + 0x30;
            LCD_disp_char(4,1,ADC_Value);
            ADC_Result=ADC_Result/10;
            ADC_Value=ADC_Result%10 + 0x30;
            LCD_disp_char(3,1,ADC_Value);
            ADC_Result=ADC_Result/10;
            ADC_Value=ADC_Result%10 + 0x30;
            LCD_disp_char(2,1,'.');
            LCD_disp_char(1,1,ADC_Value);
            AD_Start();
          }
          else
          {
            NOP();
          }
         
 }
 /* End user code. Do not edit comment generated here */
}
AD中断函数:
__interrupt void MD_INTAD(void)
{
 /* Start user code. Do not edit comment generated here */
        ADC_Result=ADCR;
       // ADC_Result=ADC_Result>>5;
        ADC_done  = MD_SET;
 /* End user code. Do not edit comment generated here */
}
视频稍后上传

菜鸟
2012-09-28 08:57:34     打赏
18楼
Renesas @EEPW

HaHaHaHa

共18条 2/2 1 2 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]