微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > DSP学习交流 > 我想让LED等累加1,然后在LCD上显示实时的累加值。 请大神帮我改改程序。 不知道哪里错了

我想让LED等累加1,然后在LCD上显示实时的累加值。 请大神帮我改改程序。 不知道哪里错了

时间:10-02 整理:3721RD 点击:

#include "DSP2833x_Device.h"     // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h"   // DSP2833x Examples Include File
//#include "f2812a.h"
#define LED (*(unsigned short int *)0x180000)
#define SRAM_Base_Adress 0x100000
#define LCDDELAY 1
#define LCDCMDTURNON 0x3f
#define LCDCMDTURNOFF 0x3e
#define LCDCMDSTARTLINE 0xc0
#define LCDCMDPAGE 0xb8
#define LCDCMDVERADDRESS 0x40
#define CTRGR *(int *)0x208000
#define CTRLCDCMDR *(int *)0x208001
#define CTRKEY *(int *)0x208001
#define CTRLCDCR *(int *)0x208002
#define CTRCLKEY *(int *)0x208002
#define CTRLCDLCR  *(int *)0x208003
#define CTRLCDRCR *(int *)0x208004
#define CTRLA *(int *)0x208005
#define CTRLR *(int *)0x208007
void Delay1(unsigned int nTime);  // 延时子程序
void Delay(unsigned int nTime);  // 延时子程序
void TurnOnLCD();   // 打开显示
void LCDCLS();    // 清除屏幕显示内容
unsigned char ledkey[12][8]=
{
{0x00,0x00,0x7C,0x82,0x82,0x82,0x7C,0x00}, //0
{0x00,0x00,0x00,0x84,0xFE,0x80,0x00,0x00}, //1
{0x00,0x00,0x84,0xC2,0xA2,0x92,0x8C,0x00}, //2
{0x00,0x00,0x44,0x92,0x92,0x92,0x6C,0x00},
{0x00,0x00,0x30,0x28,0x24,0xFE,0x20,0x00},
{0x00,0x00,0x4E,0x92,0x92,0x92,0x62,0x00},
{0x00,0x00,0x7C,0x92,0x92,0x92,0x64,0x00},
{0x00,0x00,0x02,0xC2,0x32,0x0A,0x06,0x00},
{0x00,0x00,0x6C,0x92,0x92,0x92,0x6C,0x00},
{0x00,0x00,0x4C,0x92,0x92,0x92,0x7C,0x00}
};
void main(void)
{
   int i,nCount=0,nBW=0;
   long a;
   InitSysCtrl();
   InitXintf16Gpio();
   InitPieCtrl();
    IER = 0x0000;
    IFR = 0x0000;
CTRGR=0x80;  // 初始化ICETEK-CTR
Delay(LCDDELAY);
CTRGR=0x0;
Delay(LCDDELAY);
CTRGR=0x80;
Delay(LCDDELAY);
CTRLR=0;   // 关闭东西方向的交通灯
Delay(LCDDELAY);
CTRLR=0x40; // 关闭南北方向的交通灯
Delay(LCDDELAY);
TurnOnLCD();    // 打开显示
LCDCLS();    // 清除显示内存
CTRLCDCMDR=LCDCMDSTARTLINE;  // 设置显示起始行
Delay(LCDDELAY);
CTRLCDCR=0;
Delay(LCDDELAY);
for (;;)
{
  CTRLCDCMDR=LCDCMDPAGE;  // 设置操作页=0
  Delay(LCDDELAY);
  CTRLCDCR=0;
  Delay(LCDDELAY);
  CTRLCDCMDR=LCDCMDVERADDRESS; // 起始列=0
  Delay(LCDDELAY);
  CTRLCDCR=0;
  Delay(LCDDELAY);
  for(a=0;a<=9;a++)
  {
   {  LED=a;}
    Delay(3000);
    }
  for (i=0;i<8;i=LED )
    {
     CTRLCDLCR=( nBW==0 )?(ledkey[nCount]):(~ledkey[nCount]);// 屏幕左侧第1至8行第i列赋值       port8002=0;   // (赋值后当前操作列自动加1,所以不需设置)
     Delay(LCDDELAY);
     CTRLCDCR=0;
     Delay(3000); //延时子程序
       nCount++;
  }
  if ( nCount==10 )
  {
   nCount=0;
   nBW=1-nBW;
  }
}
void Delay(unsigned int nDelay)
  {
   int ii,jj,kk=0;
   for ( ii=0;ii<nDelay;ii++ )
   {
    for ( jj=0;jj<512;jj++ )
    {
      kk++;
     }
    }
  }
void Delay1(unsigned int nDelay)
{
  int a,j,k=0;
   for(a=0;a<nDelay;a++)
    {
      for(j=0;j<1024;j++)
      {
         k++;
      }
    }
}
void TurnOnLCD()
{
  CTRLCDCMDR=LCDCMDTURNON;
  Delay(LCDDELAY);
  CTRLCDCR=0;
  Delay(2048);
  CTRLCDCMDR=LCDCMDSTARTLINE;
  Delay(LCDDELAY);
  CTRLCDCR=0;
  Delay(LCDDELAY);
}
void LCDCLS()
{
  int i,j;
  CTRLCDCMDR=LCDCMDSTARTLINE;
  Delay(LCDDELAY);
  CTRLCDCR=0;
  Delay(LCDDELAY);
  for ( i=0;i<8;i++ )
  {
   CTRLCDCMDR=LCDCMDPAGE+i;
   Delay(LCDDELAY);
   CTRLCDCR=0;
   Delay(LCDDELAY);
   CTRLCDCMDR=LCDCMDVERADDRESS;
   Delay(LCDDELAY);
   CTRLCDCR=0;
   Delay(LCDDELAY);
   for ( j=0;j<64;j++ )
   {
    CTRLCDLCR=0;
    Delay(LCDDELAY);
    CTRLCDCR=0;
    Delay(LCDDELAY);
   }
   CTRLCDCMDR=LCDCMDPAGE+i;
   Delay(LCDDELAY);
   CTRLCDCR=0;
   Delay(LCDDELAY);
   CTRLCDCMDR=LCDCMDVERADDRESS;
   Delay(LCDDELAY);
   CTRLCDCR=0;
   Delay(LCDDELAY);
   for ( j=0;j<64;j++ )
   {
    CTRLCDRCR=0;
    Delay(LCDDELAY);
    CTRLCDCR=0;
    Delay(LCDDELAY);
   }
  }
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top